Expand description
Color science utilities: color spaces, palettes, gradients, LUT generation.
Provides conversion between linear RGB, sRGB, HSV, HSL, Oklab, CIE Lab, CIE LCH, and XYZ color spaces. Also includes gradient building, palette generation, color harmonies, and LUT support.
Structs§
- Color
Stop - A color stop in a gradient.
- Gradient
- A multi-stop color gradient.
- Hsl
- HSL color: hue in
[0, 360), saturation and lightness in[0, 1]. - Hsv
- HSV color: hue in
[0, 360), saturation and value in[0, 1]. - Lab
- CIE Lab* color space (D65 white point).
- Lch
- CIE LCH (Lightness, Chroma, Hue in degrees).
- Oklab
- Oklab color: a perceptually uniform color space by Björn Ottosson.
L= lightness [0,1],aandbare chroma axes (approx −0.5..0.5). - Palette
- A named palette of colors.
- Rgba
- Linear RGB color with alpha, all in
[0.0, 1.0]. - Xyz
- CIE XYZ (D65 white point).
Enums§
- Gradient
Mode - Interpolation mode for gradient stops.
Functions§
- adjust_
brightness - Adjust brightness (additive offset).
- adjust_
contrast - Adjust contrast around 0.5 midpoint (factor >1 = more contrast).
- adjust_
hue - Adjust hue by
deltadegrees. - adjust_
saturation - Saturate or desaturate (1 = no change, 0 = greyscale, >1 = boost).
- analogous
- Generate analogous colors (±30°).
- complementary
- Generate a complementary color (180° hue rotation).
- distance_
lab_ e76 - Perceptual distance using CIE Lab Delta-E 1976.
- distance_
rgb - Euclidean distance in linear RGB space.
- gradient_
fire - gradient_
health - gradient_
ice - gradient_
inferno - gradient_
neon - gradient_
plasma - gradient_
viridis - hsl_
to_ rgb - hsv_
to_ rgb - linear_
to_ srgb - linear_
to_ srgb_ channel - Apply sRGB gamma (linear → display).
- nearest_
in_ palette - Find the nearest color in a palette (by Lab Delta-E).
- palette_
ansi16 - ANSI 16-color terminal palette.
- palette_
chaos_ elements - Chaos RPG element colors.
- palette_
crt - CRT terminal / retrowave palette.
- rgb_
to_ hsl - rgb_
to_ hsv - shade_
black - Mix color
cwith black byfactor ∈ [0, 1](0 = original, 1 = black). - split_
complementary - Generate split-complementary colors (150° and 210°).
- srgb_
to_ linear - srgb_
to_ linear_ channel - Remove sRGB gamma (display → linear).
- tetradic
- Generate a tetradic (square) color scheme.
- tint_
white - Mix color
cwith white byfactor ∈ [0, 1](0 = original, 1 = white). - tonemap_
aces - ACES filmic tone mapping approximation (Narkowicz 2015).
- tonemap_
reinhard - Reinhard tone mapping operator.
- tonemap_
uncharted2 - Uncharted 2 “Hable” filmic tone mapping.
- triadic
- Generate triadic colors (120° apart).