pub enum ColorMap {
Viridis,
Magma,
Turbo,
GrayScale,
RdBu,
Custom {
stops: Vec<Color>,
},
}Expand description
A continuous colour ramp.
The named ramps are fieldless so a host UI can list them in a dropdown and
they cross the wasm boundary as plain integers, following
crate::preset::ColorCycle. Custom carries its own stops for hosts that
need a ramp figgy does not ship.
Variants§
Viridis
Perceptually uniform blue→green→yellow. The safe default for unsigned magnitudes.
Magma
Perceptually uniform black→purple→orange→white.
Turbo
High-contrast rainbow. Reads well for fine structure, poor for judging magnitude — and unreadable in greyscale print.
GrayScale
Black→white. For print, and for overlaying contour lines on top.
RdBu
Diverging red→white→blue. For signed data around a meaningful zero;
set axis.min = -axis.max or the white midpoint lands off zero and the
ramp lies about the sign.
Custom
Implementations§
Source§impl ColorMap
impl ColorMap
Sourcepub fn sample(&self, t: f32) -> Color
pub fn sample(&self, t: f32) -> Color
Colour at normalized position t.
t is clamped to [0, 1], so a caller that has not normalized its z
range gets the endpoint colour rather than an out-of-range index. NaN
clamps to the low end — but a NaN z should be drawn with the
colourbar’s nan_color instead of being pushed through here, because
“missing” and “smallest” are different facts.
Sourcepub fn lut(&self) -> [Color; 256]
pub fn lut(&self) -> [Color; 256]
The ramp baked to LUT_LEN entries.
A convenience for callers that want the ramp as a table — a legend image,
a texture upload of their own. figgy’s own paths do not use it: the
colourbar strip and field_columnar.wgsl both evaluate
Self::sample over the same stops, which is what makes their colours
agree exactly instead of within a quantization step.