# Color v0.4.0 - Table of Contents A comprehensive color library: 21 color spaces, chromatic adaptation, ICC rendering intents, ΔE2000 / WCAG / APCA contrast, gamut mapping, color mixing and gradients, blend modes, color harmonies, color temperature, spectral pipeline, and a full CSS Color 4 / 5 parser. Zero runtime dependencies. ## Pages - [Color](readme.md) - [License](license.md) - [Changelog](changelog.md) ## Modules - [Color](Color.md): Top-level color conversion dispatch. - [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.Mix](Color.Mix.md): Color interpolation and gradient generation. - [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. - 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.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.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.