Skip to main content

apply_colormap

Function apply_colormap 

Source
pub fn apply_colormap(t: f64, name: &str) -> (u8, u8, u8)
Expand description

Maps a normalised value t ∈ [0, 1] to an (R, G, B) triple.

Values outside [0, 1] are clamped. Unrecognised names fall back to "viridis".

§Examples

use ccalc_plot::colormap::apply_colormap;
let (r, g, b) = apply_colormap(0.0, "gray");
assert_eq!((r, g, b), (0, 0, 0));
let (r, g, b) = apply_colormap(1.0, "gray");
assert_eq!((r, g, b), (255, 255, 255));