Skip to main content

band_coord

Function band_coord 

Source
pub fn band_coord(t: f32, steps: f32) -> f32
Expand description

Quantize a palette coordinate onto steps hard bands — the canonical definition every LUT sample site in the engine mirrors (module docs).

t' = (floor(t·N) + 0.5)/N lands on each band’s centre, so the colour a band takes is the one the smooth ramp had in the middle of it rather than at its edge. Below MIN_ACTIVE_STEPS (tested as < 1.5, since band_steps has already rounded) the coordinate passes through untouched — the exact identity, which is what keeps every shipped preset and every golden baseline byte-identical.

Negative and above-1 coordinates are fine and are the common case: the LUT is repeat-addressed, so a color_span above 1 wraps it, and floor keeps the quantization aligned across every wrap.