Skip to main content

Module color

Module color 

Source
Expand description

The single value type the theme engine passes around.

Stored as OKLCH (perceptually uniform). sRGB hex strings are an I/O concern only — from_hex is the inbound door, to_hex the outbound. Engine math (mix, lighten, darken, hue distance, chroma checks) all happens in OKLCH or OKLab and never round-trips through gamma-encoded sRGB.

The OKLab matrices are Björn Ottosson’s published constants (https://bottosson.github.io/posts/oklab/). They are embedded literally rather than computed at runtime so this file stays self-contained and cargo expand-friendly.

Structs§

Color
A color stored in OKLCH. All engine math happens in this space.

Enums§

ColorError
Failure mode of Color::from_hex. Returned instead of panicking because the engine accepts client-supplied strings.

Functions§

hue_distance
Shortest angular distance between two hues, in degrees 0.0..=180.0. Used by §7 to gap brand vs state colors and by §6 to score role fit.