Map a difference magnitude (0..1) to a false-color hot palette so small errors stay dark and big errors scream. Goes black → red → yellow → white, amplified so typical-tolerance errors (1-2%) are visible without manually setting a gain.
(magnitude: f32)
| 238 | /// yellow → white, amplified so typical-tolerance errors (1-2%) are |
| 239 | /// visible without manually setting a gain. |
| 240 | fn heatmap_color(magnitude: f32) -> Rgb<u8> { |
| 241 | let m = (magnitude * 16.0).clamp(0.0, 1.0); |
| 242 | let r = (m * 3.0).clamp(0.0, 1.0); |
| 243 | let g = ((m - 0.33) * 3.0).clamp(0.0, 1.0); |
| 244 | let b = ((m - 0.66) * 3.0).clamp(0.0, 1.0); |
| 245 | Rgb([ |
| 246 | (r * 255.0) as u8, |
| 247 | (g * 255.0) as u8, |
| 248 | (b * 255.0) as u8, |
| 249 | ]) |
| 250 | } |
| 251 | |
| 252 | fn write_heatmap( |
| 253 | reference: &[[f32; 3]], |
no outgoing calls
no test coverage detected