{ h, s, v, alpha }.
{ h, w, b, alpha }.
{ l, a, b, alpha }.
{ l, c, h, alpha }.
{ r, g, b, alpha }, channels 0–255.
This colour's coordinates and alpha, in its own space.
#RRGGBB, or #RRGGBBAA when not opaque. Uppercase.
rgb(r,g,b) or rgba(r,g,b,a) — the only syntax a MapLibre style may contain.
Whatever space this colour is held in, it is converted and, if need be, gamut-mapped on the way
out, because MapLibre's native parser reads neither oklch() nor CSS's space-separated rgb()
and renders what it cannot read as nothing at all.
Shifts toward black (negative) or white (positive), by up to one whole channel range.
Returns this colour.
A Color is frozen and every method returns a new instance, so there is nothing a copy could
protect against. It stays because v5 had it, and because the duck-typed clone convention is
what a generic deep-copy would look for.
Scales each channel around mid-grey. 0 collapses to #808080; above 1 increases contrast.
WCAG 2.1 contrast ratio against another colour, 1 to 21. Alpha is ignored.
Toward black. Theme-absolute: use blend(ratio, fg) for something that follows the palette.
Perceptual distance in OKLab. Below 0.02 — one JND — is a difference nobody can see.
Per-channel gamma: c → 255 · (c/255)^value. Below 1 brightens midtones, above 1 darkens them.
Whether this colour's hue channel carries information, or is grey reading rounding noise.
Whether a screen can show this colour without help.
Flips every channel: c → 255 − c. Flips the hue too — for dark mode use invertLuminosity.
Flips lightness while keeping hue and saturation — the dark-mode inversion.
Toward white. Theme-absolute: use blend(ratio, bg) for something that follows the palette.
WCAG 2.1 relative luminance, 0 for black and 1 for white.
Mixes toward other, t of the way, in OKLab unless told otherwise.
Optionaloptions: MixOptionsThe same colour, fully opaque.
A copy with its coordinates rounded — integers for sRGB, digits decimals elsewhere.
Shifts this colour's hue toward other's, keeping its own lightness and saturation.
A colour with no hue to give — white, black or any grey — leaves this one alone. v5 read such a colour's hue as a real 0°, so tinting toward white turned everything red.
CSS syntax, in this colour's own space or another: oklch(0.7 0.15 45). Not for style output.
Optionalprecision: numberThe nearest colour a screen can show, holding lightness and hue (CSS Color 4 §14.2.1).
Returns a string representation of an object.
StaticfromStatichslHue 0–360, saturation and lightness 0–100.
StatichsvHue 0–360, saturation and value 0–100. Not a CSS space; kept for randomColor.
StatichwbHue 0–360, whiteness and blackness 0–100.
StaticmixTwo colours mixed, t of the way across. Interpolates in OKLab unless told otherwise.
Optionaloptions: MixOptionsStaticoklabLightness 0–1, opponent axes roughly ±0.4.
StaticoklchLightness 0–1, chroma from 0, hue 0–360.
StaticparseStaticsrgb
{ h, s, l, alpha }.