aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hittekaart/src/renderer/heatmap.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/hittekaart/src/renderer/heatmap.rs b/hittekaart/src/renderer/heatmap.rs
index 6400e82..d2c2452 100644
--- a/hittekaart/src/renderer/heatmap.rs
+++ b/hittekaart/src/renderer/heatmap.rs
@@ -140,6 +140,13 @@ fn prepare_lut(max: u8) -> Vec<Rgba<u8>> {
iter::once([0, 0, 0, 0].into())
.chain((1..=max).map(|count| {
let alpha = count as f64 / max as f64;
+ // If we simply use alpha here, we get a linear mapping, and a jump from 1 to 2
+ // repetitions is worth as much as a jump from 9 to 10. By transforming alpha via the
+ // cubic function given below, we give more weight to the "early" repetitions by having
+ // a steeper slope, and less weight to later repetitions.
+ // There is no science behind the power 3, others work as well (if you adjust the
+ // sign). It seemed like a decent trade-off though.
+ let alpha = (alpha - 1.0).powi(3) + 1.0;
let color = gradient.at(1.0 - alpha);
color.to_rgba8().into()
}))