Page
Library
Module
Module type
Parameter
Class
Class type
Source
Hugin.ColorSourcePerceptually uniform OKLCH colors.
Perceptually uniform colors.
Colors are represented internally in the OKLCH color space. All operations (lighten, darken, mix) produce perceptually uniform results: equal numerical steps yield equal perceived differences.
Constructors accept common input formats (sRGB, hex) and convert to OKLCH on creation. The reverse conversion to_rgba is called only at render time.
The type for colors in OKLCH space. Components are lightness [0, 1], chroma [0, ~0.4], hue [0, 360), and alpha [0, 1].
oklch ~l ~c ~h () is the fully opaque OKLCH color with lightness l, chroma c, and hue h (in degrees).
oklcha ~l ~c ~h ~a () is like oklch with alpha a.
rgb ~r ~g ~b () is the fully opaque color with sRGB components r, g, b in [0, 1], converted to OKLCH.
rgba ~r ~g ~b ~a () is like rgb with alpha a.
hex s is the color parsed from the hex string s. Accepts "#RRGGBB" and "#RRGGBBAA" formats.
Raises Invalid_argument if s is not a valid hex color.
to_rgba c is (r, g, b, a) with sRGB components in [0, 1]. Values are clamped to the sRGB gamut.
lighten amount c is c with lightness increased by amount, clamped to [0, 1].
darken amount c is c with lightness decreased by amount, clamped to [0, 1].
mix ratio a b is the perceptual blend of a and b. ratio is the interpolation factor: 0.0 gives a, 1.0 gives b. Hue is interpolated along the shortest arc.
The default named colors follow the Okabe-Ito palette, designed to be distinguishable under all forms of color-vision deficiency.
pp formats the color as oklch(L C H / A).