From 38b533918afe4c12de1042d0cb8bf690c4ed0b8b Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Fri, 28 Nov 2025 23:07:48 +0100 Subject: apply cubic scaling to heat count --- hittekaart/src/renderer/heatmap.rs | 7 +++++++ 1 file changed, 7 insertions(+) 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> { 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() })) -- cgit v1.2.3