trees: extend temperature() to purple
This commit is contained in:
parent
8b20c84638
commit
0364650831
|
@ -155,13 +155,16 @@ pub fn get_heatmap(state: State) -> (State, Response<Body>) {
|
|||
(state, res)
|
||||
}
|
||||
|
||||
// 0.0: green, 0.5: yellow, 1.0: red
|
||||
/// 0.0: green, 0.4: yellow, 0.8: red, 1.0: purple
|
||||
fn temperature(mut x: f64) -> (f64, f64, f64) {
|
||||
x = x.max(0.).min(1.);
|
||||
|
||||
if x < 0.5 {
|
||||
(2.0 * x, 1.0, 0.0)
|
||||
const MAX: f64 = 0.85;
|
||||
if x < 0.4 {
|
||||
(MAX * x / 0.4, MAX, 0.0)
|
||||
} else if x < 0.8 {
|
||||
(MAX, MAX - MAX * (x - 0.4) / 0.4, 0.0)
|
||||
} else {
|
||||
(1.0, 2.0 - 2.0 * x, 0.0)
|
||||
(MAX, 0.0, MAX * (x - 0.8) / 0.2)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue