aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2026-04-12 16:13:54 +0200
committerDaniel Schadt <kingdread@gmx.de>2026-04-12 16:15:29 +0200
commit63225422e594c38b7f04d1189f6f78b1409f207a (patch)
tree8522c1c9719d02f64e24599442d628f6f1b69a74
parentb580d82834c0973a344e3dafd6979204c5364047 (diff)
downloadhittekaart-63225422e594c38b7f04d1189f6f78b1409f207a.tar.gz
hittekaart-63225422e594c38b7f04d1189f6f78b1409f207a.tar.bz2
hittekaart-63225422e594c38b7f04d1189f6f78b1409f207a.zip
adjust gradientHEADmaster
-rw-r--r--CHANGELOG.adoc4
-rw-r--r--hittekaart/src/renderer/heatmap.rs11
2 files changed, 11 insertions, 4 deletions
diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc
index eeb2bc0..32bc6a5 100644
--- a/CHANGELOG.adoc
+++ b/CHANGELOG.adoc
@@ -8,6 +8,10 @@ Added:
- The `storage::OsmAnd` and `storage::MbTiles` formats
+Changed:
+
+- The gradient color scaling.
+
Removed:
- The `storage::Sqlite` struct (`storage::OsmAnd` can be used instead)
diff --git a/hittekaart/src/renderer/heatmap.rs b/hittekaart/src/renderer/heatmap.rs
index c678a7a..5090935 100644
--- a/hittekaart/src/renderer/heatmap.rs
+++ b/hittekaart/src/renderer/heatmap.rs
@@ -137,7 +137,10 @@ fn colorize_tile(tile: &ImageBuffer<Luma<u8>, Vec<u8>>, lut: &[Rgba<u8>]) -> Rgb
}
fn prepare_lut(max: u8) -> Vec<Rgba<u8>> {
- let gradient = colorgrad::preset::yl_or_rd();
+ let gradient = colorgrad::GradientBuilder::new()
+ .css("rgba(0, 0, 0, 1) 0%, rgba(164, 0, 0, 1) 25%, rgba(224, 5, 0, 1) 50%, rgba(255, 187, 15, 1) 75%, rgba(255, 255, 255, 1) 100%")
+ .build::<colorgrad::LinearGradient>()
+ .unwrap();
iter::once([0, 0, 0, 0].into())
.chain((1..=max).map(|count| {
let alpha = count as f32 / max as f32;
@@ -145,10 +148,10 @@ fn prepare_lut(max: u8) -> Vec<Rgba<u8>> {
// 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
+ // There is no science behind the power 7, 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);
+ let alpha = (alpha - 1.0).powi(7) + 1.0;
+ let color = gradient.at(alpha);
color.to_rgba8().into()
}))
.collect()