Skip to main content

Module ramp

Module ramp 

Source
Expand description

Theme-derived colour ramps. No hardcoded palette: a sequential ramp is built from the theme’s bg → accent → glow, and a diverging ramp from accent (low) through a neutral midpoint to glow (high). Charts call Ramp::at with a normalised t ∈ 0..=1 to map a scalar to a colour.

Keeping this purely a function of facett_core::Theme means every chart re-skins automatically when the theme switches — the requirement that no component bakes in its own colours.

Structs§

Ramp
A colour ramp sampled at t ∈ 0..=1. Built from theme colours so it follows the active palette.

Functions§

lerp_color
Linear interpolation between two colours in straight (unmultiplied) sRGB space. t is clamped to 0..=1; each channel is rounded and clamped so a degenerate t can never wrap a u8. Cheap and good enough for chart fills, heat cells and ramps.
normalize
Normalise v into 0..=1 over [min, max]. Degenerate ranges map to 0.5 (a flat mid-tone) rather than dividing by zero.