# Color v0.12.1 - API Reference

## Modules

- [Color](Color.md): Top-level color conversion dispatch.
- [Color.AppleRGB](Color.AppleRGB.md): Apple RGB color space, using the Lindbloom Apple RGB working space
(primaries from the original Apple 13" RGB display, D65 reference
white) and simple gamma companding with `γ = 1.8`.
- [Color.Behaviour](Color.Behaviour.md): Behaviour implemented by every color-space struct module in the
library.
- [Color.Blend](Color.Blend.md): CSS Compositing and Blending Level 1 blend modes.
- [Color.CSS.Names](Color.CSS.Names.md): The 148 named colors defined by CSS Color Module Level 4, mapped to
their 8-bit sRGB values.
- [Color.ChromaticAdaptation](Color.ChromaticAdaptation.md): Chromatic adaptation transforms between reference whites.
- [Color.Contrast](Color.Contrast.md): Contrast and luminance computations.
- [Color.Distance](Color.Distance.md): Color difference (ΔE) metrics between two colors.
- [Color.Gamut](Color.Gamut.md): Gamut checking and gamut mapping.
- [Color.Harmony](Color.Harmony.md): Color harmony helpers — rotations and named combinations on the hue
circle.
- [Color.Material](Color.Material.md): A physically-based-rendering (PBR) material wrapper around a
base colour.
- [Color.Mix](Color.Mix.md): Color interpolation and gradient generation.
- [Color.Palette.Sort](Color.Palette.Sort.md): Sort a list of colours into a perceptually-ordered sequence.
- [Color.Rec2020](Color.Rec2020.md): ITU-R BT.2020 / Rec. 2020 color space, using the Rec. 2020 wide-gamut
primaries (D65 reference white) and the BT.2020 SDR opto-electronic
transfer function at 12-bit precision.
- [Color.Sigil](Color.Sigil.md): A sigil for writing color literals in code. Import this module and
use `~COLOR` to build any supported color.
- [Color.Spectral](Color.Spectral.md): Spectral power distributions, spectral reflectances, and spectrum →
XYZ integration.
- [Color.Temperature](Color.Temperature.md): Correlated colour temperature (CCT) on the Planckian locus.
- [Color.Tristimulus](Color.Tristimulus.md): Authoritative source of illuminant reference white data.

- Color Spaces
  - [Color.AdobeRGB](Color.AdobeRGB.md): Adobe RGB (1998) color space, using the Lindbloom Adobe working space
(primaries from Adobe RGB (1998) specification, D65 reference white)
and simple gamma companding with `γ = 2.19921875`.
  - [Color.CAM16UCS](Color.CAM16UCS.md): CAM16-UCS perceptual color space.
  - [Color.CMYK](Color.CMYK.md): Device CMYK color space. This is the simple "subtractive from sRGB"
device CMYK — it does NOT use an ICC profile, so it is not suitable
for color-accurate print workflows. For that, pass the sRGB (or
AdobeRGB) struct through a real CMS.
  - [Color.HPLuv](Color.HPLuv.md): HPLuv — the "pastel" sibling of HSLuv.
  - [Color.HSL](Color.HSL.md): HSL color space — hue, saturation, lightness.
  - [Color.HSLuv](Color.HSLuv.md): HSLuv — a perceptually-uniform alternative to HSL, built on CIELUV.
  - [Color.HSV](Color.HSV.md): HSV color space — hue, saturation, value.
  - [Color.ICtCp](Color.ICtCp.md): ICtCp color space (ITU-R BT.2100).
  - [Color.IPT](Color.IPT.md): IPT perceptual color space (Ebner & Fairchild, 1998).
  - [Color.JzAzBz](Color.JzAzBz.md): JzAzBz perceptually-uniform color space for HDR and wide-gamut
content, from Safdar, Cui, Kim & Luo (2017), "Perceptually uniform
color space for image signals including high dynamic range and wide
gamut".
  - [Color.LCHab](Color.LCHab.md): Cylindrical representation of CIE `L*a*b*`: lightness, chroma, hue.
  - [Color.LCHuv](Color.LCHuv.md): Cylindrical representation of CIE `L*u*v*`: lightness, chroma, hue.
  - [Color.Lab](Color.Lab.md): CIE 1976 `L*a*b*` color space.
  - [Color.Luv](Color.Luv.md): CIE 1976 `L*u*v*` color space.
  - [Color.Oklab](Color.Oklab.md): Oklab perceptual color space (Björn Ottosson, 2020).
  - [Color.Oklch](Color.Oklch.md): Cylindrical representation of Oklab: lightness, chroma, hue.
  - [Color.RGB](Color.RGB.md): Linear (un-companded) RGB relative to a named working space.
  - [Color.SRGB](Color.SRGB.md): sRGB color space, using the Lindbloom sRGB working space
(primaries from IEC 61966-2-1, D65 reference white) and the sRGB
companding function.
  - [Color.XYZ](Color.XYZ.md): CIE 1931 XYZ tristimulus color space.
  - [Color.XyY](Color.XyY.md): CIE xyY color space — chromaticity coordinates `x`, `y` and luminance `Y`.
  - [Color.YCbCr](Color.YCbCr.md): YCbCr digital-video color space with BT.601, BT.709 and BT.2020
variants.

- CSS Colors
  - [Color.CSS](Color.CSS.md): CSS Color Module Level 4 / 5 parsing and serialisation.
  - [Color.CSS.Calc](Color.CSS.Calc.md): A tiny `calc()` expression evaluator for CSS color components.
  - [Color.CSS.Tokenizer](Color.CSS.Tokenizer.md): A small, paren-aware tokenizer for the bodies of CSS color
functions (`rgb(...)`, `hsl(...)`, `lab(...)`, `color(...)`,
`device-cmyk(...)`, etc).

- Conversion Math
  - [Color.Conversion.Lindbloom](Color.Conversion.Lindbloom.md): Color space conversion functions based on the formulas published by
Bruce Lindbloom at http://www.brucelindbloom.com/index.html?Math.html.
  - [Color.Conversion.Oklab](Color.Conversion.Oklab.md): Pure math for the Oklab perceptual color space, published by
Björn Ottosson in 2020 (https://bottosson.github.io/posts/oklab/).

- ANSI
  - [Color.ANSI](Color.ANSI.md): ANSI SGR (Select Graphic Rendition) colour parsing and encoding.

- LED
  - [Color.LED](Color.LED.md): Colour conversion for multi-channel addressable LEDs — fixtures
with one or more extra **white** channels alongside R, G, B.
  - [Color.LED.RGBW](Color.LED.RGBW.md): A four-channel **RGBW** LED pixel — red, green, blue plus one
fixed-temperature white channel.
  - [Color.LED.RGBWW](Color.LED.RGBWW.md): A five-channel **RGBWW** / **RGB+CCT** LED pixel — red, green,
blue plus a **warm white** and a **cool white** channel.

- Palettes
  - [Color.Palette](Color.Palette.md): Palette generation for design systems and web sites.
  - [Color.Palette.Contrast](Color.Palette.Contrast.md): A **contrast-targeted** palette — shades of a seed colour chosen
so each stop hits a specific contrast ratio against a fixed
background.
  - [Color.Palette.ContrastScale](Color.Palette.ContrastScale.md): A **contrast-constrained tonal scale** — the hybrid algorithm
described by Matt Ström-Awn in
[*Generating colour palettes with math*](https://mattstromawn.com/writing/generating-color-palettes/).
  - [Color.Palette.Theme](Color.Palette.Theme.md): A complete **theme** — a coordinated set of five tonal scales —
generated from a single seed colour.
  - [Color.Palette.Tonal](Color.Palette.Tonal.md): A **tonal scale** — N shades of one hue, from light to dark —
generated from a single seed colour.

- Visualizer
  - [Color.Palette.Visualizer](Color.Palette.Visualizer.md): A web-based visualizer for the palettes produced by
`Color.Palette`.
  - [Color.Palette.Visualizer.Standalone](Color.Palette.Visualizer.Standalone.md): A tiny helper that runs `Color.Palette.Visualizer` as a
standalone web server for local development.

- Design Tokens
  - [Color.DesignTokens](Color.DesignTokens.md): Encode and decode W3C [Design Tokens Community Group](https://www.designtokens.org/)
**color** tokens, per the October 2025 draft of the
[DTCG Color spec](https://www.designtokens.org/tr/2025.10/color/).

- Gamut Diagrams
  - [Color.Gamut.Diagram](Color.Gamut.Diagram.md): Geometric primitives for drawing **chromaticity diagrams** —
the "horseshoe" plots used to visualise gamuts side-by-side.
  - [Color.Gamut.SVG](Color.Gamut.SVG.md): Renders a chromaticity diagram — the horseshoe, gamut
triangles, Planckian locus, and optional palette / seed
overlays — as a self-contained SVG string.

- ICC
  - [Color.ICC.ParseError](Color.ICC.ParseError.md): Raised when `Color.ICC.Profile.load/1` or `parse/1` cannot interpret
an ICC profile.
  - [Color.ICC.Profile](Color.ICC.Profile.md): Reader for ICC v2 / v4 **matrix profiles** — the form used by
`sRGB IEC61966-2.1.icc`, `Display P3.icc`, `AdobeRGB1998.icc`,
`Generic Lab Profile.icc`, and most camera and scanner profiles.

- Exceptions
  - [Color.ANSI.ParseError](Color.ANSI.ParseError.md): Raised when `Color.ANSI.parse/1` cannot interpret an ANSI SGR
escape sequence.
  - [Color.DesignTokensDecodeError](Color.DesignTokensDecodeError.md): Raised (or returned) when a Design Tokens (DTCG 2025.10) token
cannot be decoded into a `Color.*` struct.
  - [Color.InvalidColorError](Color.InvalidColorError.md): Raised when `Color.new/1,2` cannot interpret its input as a color.
  - [Color.InvalidComponentError](Color.InvalidComponentError.md): Raised when one or more channel values fall outside the legal range
for a color space, are the wrong numeric type, or contain `NaN` /
infinity.
  - [Color.InvalidHexError](Color.InvalidHexError.md): Raised when a hex color string cannot be parsed.
  - [Color.MissingWorkingSpaceError](Color.MissingWorkingSpaceError.md): Raised when `Color.convert/2` is called with `Color.RGB` as the
target. Linear `Color.RGB` requires a named working space, supplied
via `Color.convert/3` or `convert/4`.
  - [Color.PaletteError](Color.PaletteError.md): Raised when a palette cannot be generated — typically because of
invalid options (bad stop list, out-of-range anchor, unreachable
contrast target, etc.).
  - [Color.ParseError](Color.ParseError.md): Raised when CSS Color Module Level 4 parsing fails. Used by
`Color.CSS.parse/1`, `Color.CSS.Tokenizer`, and `Color.CSS.Calc`.
  - [Color.UnknownBlendModeError](Color.UnknownBlendModeError.md): Raised when `Color.Blend.blend/3` is called with an unknown blend
mode.
  - [Color.UnknownColorNameError](Color.UnknownColorNameError.md): Raised when a CSS named-color lookup fails.
  - [Color.UnknownColorSpaceError](Color.UnknownColorSpaceError.md): Raised when an atom or module passed as a color-space identifier is
not recognised.
  - [Color.UnknownGamutMethodError](Color.UnknownGamutMethodError.md): Raised when `Color.Gamut.to_gamut/3` is called with an unknown
gamut-mapping method.
  - [Color.UnknownIlluminantError](Color.UnknownIlluminantError.md): Raised when an illuminant atom is not recognised by
`Color.Tristimulus`.
  - [Color.UnknownSortKeyError](Color.UnknownSortKeyError.md): Raised when `Color.sort/2` is called with a `:by` value that is
neither a recognised preset atom nor a 1-arity function.
  - [Color.UnknownWorkingSpaceError](Color.UnknownWorkingSpaceError.md): Raised when an RGB working-space identifier or its CSS Color 4 name
is not recognised.
  - [Color.UnsupportedTargetError](Color.UnsupportedTargetError.md): Raised when `Color.convert/2,3,4` is called with a target module
that is not part of the supported color-space hub.

- Helpers
  - [Color.HSLuv.Gamut](Color.HSLuv.Gamut.md): Helpers that compute the sRGB gamut boundary inside CIELUV for
HSLuv and HPLuv.
  - [Color.RGB.WorkingSpace](Color.RGB.WorkingSpace.md)
  - [Color.Spectral.Tables](Color.Spectral.Tables.md): Standard CIE color matching functions and illuminant spectral power
distributions, tabulated at 5 nm intervals from 380 nm to 780 nm
(81 samples).
  - [Color.Types](Color.Types.md): Shared type aliases used across the `Color` library.

