@versatiles/style
    Preparing search index...

    Implements

    • ColorValue
    Index
    alpha: number
    coords: Coords
    space: Space
    • This colour's coordinates and alpha, in its own space.

      Returns [number, number, number, number]

    • #RRGGBB, or #RRGGBBAA when not opaque. Uppercase.

      Returns string

    • 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.

      Returns string

    • Linear interpolation toward other in sRGB.

      Unlike v5, alpha is interpolated too: blend(1, x) now returns x, alpha included, rather than x's channels wearing this colour's alpha.

      Parameters

      • value: number
      • other: Color

      Returns Color

    • Shifts toward black (negative) or white (positive), by up to one whole channel range.

      Parameters

      • value: number

      Returns Color

    • 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.

      Returns Color

    • Recoloured with top's hue and saturation, keeping this colour's lightness — the HSL "Color" blend mode — then blended back by top's alpha, which reads as the strength.

      Parameters

      Returns Color

    • Scales each channel around mid-grey. 0 collapses to #808080; above 1 increases contrast.

      Parameters

      • value: number

      Returns Color

    • WCAG 2.1 contrast ratio against another colour, 1 to 21. Alpha is ignored.

      Parameters

      Returns number

    • Toward black. Theme-absolute: use blend(ratio, fg) for something that follows the palette.

      Parameters

      • ratio: number

      Returns Color

    • Perceptual distance in OKLab. Below 0.02 — one JND — is a difference nobody can see.

      Parameters

      Returns number

    • Per-channel gamma: c → 255 · (c/255)^value. Below 1 brightens midtones, above 1 darkens them.

      Parameters

      • value: number

      Returns Color

    • Whether this colour's hue channel carries information, or is grey reading rounding noise.

      Returns boolean

    • Whether a screen can show this colour without help.

      Returns boolean

    • Flips every channel: c → 255 − c. Flips the hue too — for dark mode use invertLuminosity.

      Returns Color

    • Toward white. Theme-absolute: use blend(ratio, bg) for something that follows the palette.

      Parameters

      • ratio: number

      Returns Color

    • WCAG 2.1 relative luminance, 0 for black and 1 for white.

      Returns number

    • A copy with its coordinates rounded — integers for sRGB, digits decimals elsewhere.

      Parameters

      • digits: number = 3

      Returns Color

    • 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.

      Parameters

      • value: number
      • other: Color

      Returns Color

    • CSS syntax, in this colour's own space or another: oklch(0.7 0.15 45). Not for style output.

      Parameters

      • space: Space = ...
      • Optionalprecision: number

      Returns string

    • Returns a string representation of an object.

      Returns string

    • A copy with some channels replaced, named as this colour's space names them, plus alpha.

      color.to('oklch').with({ l: 0.8 }) — lighten without touching hue or chroma.

      Parameters

      Returns Color

      naming the channels this space does have, if given one it does not.

    • Hue 0–360, saturation and lightness 0–100.

      Parameters

      • h: number
      • s: number
      • l: number
      • alpha: number = 1

      Returns Color

    • Hue 0–360, saturation and value 0–100. Not a CSS space; kept for randomColor.

      Parameters

      • h: number
      • s: number
      • v: number
      • alpha: number = 1

      Returns Color

    • Hue 0–360, whiteness and blackness 0–100.

      Parameters

      • h: number
      • w: number
      • b: number
      • alpha: number = 1

      Returns Color

    • Lightness 0–1, opponent axes roughly ±0.4.

      Parameters

      • l: number
      • a: number
      • b: number
      • alpha: number = 1

      Returns Color

    • Lightness 0–1, chroma from 0, hue 0–360.

      Parameters

      • l: number
      • c: number
      • h: number
      • alpha: number = 1

      Returns Color

    • Reads a colour string — hex, rgb(), hsl(), hwb(), hsv(), oklab(), oklch() or transparent. A Color is returned unchanged, so this is safe to call on an unknown value.

      Parameters

      Returns Color

      on anything it cannot read, naming what was wrong.

    • sRGB, channels 0–255.

      Parameters

      • r: number
      • g: number
      • b: number
      • alpha: number = 1

      Returns Color