Module color.oklch

OKLCH values, degree-based hue handling, and component replacement.

Use OKLCH when perceptual lightness, chroma, and hue are more convenient than Oklab's Cartesian axes. Hue storage is deliberately raw and unbounded. Normalization, canonicalization, component replacement, and conversion remain explicit operations.

Functions

NameDescription
toOklab(color) Converts OKLCH to Cartesian Oklab coordinates.
toOklch(color) Converts Cartesian Oklab to lightness, chroma, and hue.
withChroma(color, chroma) Returns a copy of an OKLCH value with raw chroma replaced.
withHue(color, hue) Returns a copy of an OKLCH value with raw stored hue replaced.
withLightness(color, lightness) Returns a copy of an OKLCH value with raw lightness replaced.

Structs

NameDescription
OklabHue Stores an Oklab-family hue in degrees.
Oklch Stores a color as Oklab lightness, chroma, and hue.

Aliases

NameTypeDescription
OklabHued OklabHue!(double) Oklab-family hue with double storage.
OklabHuef OklabHue!(float) Oklab-family hue with float storage.
Oklchd Oklch!(double) OKLCH with double components.
Oklchf Oklch!(float) OKLCH with float components.