Liking cljdoc? Tell your friends :D

dk.simongray.colour-coded.gamut

Whether a colour lies in the gamut of a space, and the nearest colour that does.

There are three ways to bring a colour into a gamut:

  • to-gamut, the gamut mapping of CSS Color 4, lowers its chroma in OKLCH at the same lightness and hue
  • clip clamps each channel, which shifts the lightness and the hue a little, but is what browsers still do (csswg-drafts issue 9449)
  • reduce-chroma lowers its chroma in a polar space of your choice, e.g. LCH, and keeps that space's lightness and hue exactly

https://www.w3.org/TR/css-color-4/#gamut-mapping

Whether a colour lies in the gamut of a space, and the nearest colour
that does.

There are three ways to bring a colour into a gamut:

- to-gamut, the gamut mapping of CSS Color 4, lowers its chroma in OKLCH
  at the same lightness and hue
- clip clamps each channel, which shifts the lightness and the hue a
  little, but is what browsers still do (csswg-drafts issue 9449)
- reduce-chroma lowers its chroma in a polar space of your choice, e.g.
  LCH, and keeps that space's lightness and hue exactly

https://www.w3.org/TR/css-color-4/#gamut-mapping
raw docstring

clipclj/s

(clip x)
(clip x space)

The colour x in the space, by default sRGB, with each channel clamped to its range. Browsers show a colour outside the display's gamut this way today. HSL and HWB clamp in sRGB, and an unbounded space, e.g. Oklab, doesn't clamp.

The colour `x` in the `space`, by default sRGB, with each channel
clamped to its range. Browsers show a colour outside the display's gamut
this way today. HSL and HWB clamp in sRGB, and an unbounded space, e.g.
Oklab, doesn't clamp.
sourceraw docstring

epsilonclj/s

How far outside its range a channel may lie and still count as inside it. Colour.js allows the same.

How far outside its range a channel may lie and still count as inside
it. Colour.js allows the same.
sourceraw docstring

in-gamut?clj/s

(in-gamut? x)
(in-gamut? x space)

Whether the colour x lies in the gamut of the space, by default sRGB. Every colour lies in the gamut of an unbounded space, e.g. Oklab.

Whether the colour `x` lies in the gamut of the `space`, by default
sRGB. Every colour lies in the gamut of an unbounded space, e.g. Oklab.
sourceraw docstring

reduce-chromaclj/s

(reduce-chroma x space)
(reduce-chroma x space gamut-space)

The colour x in the polar space, e.g. :lch or :oklch, with its chroma lowered until it lies in the gamut of gamut-space, by default sRGB, keeping its lightness and hue in that space exactly.

The colour `x` in the polar `space`, e.g. :lch or :oklch, with its chroma
lowered until it lies in the gamut of `gamut-space`, by default sRGB,
keeping its lightness and hue in that space exactly.
sourceraw docstring

to-gamutclj/s

(to-gamut x)
(to-gamut x space)

The colour x in the gamut of the space, by default sRGB, at the same OKLCH lightness and hue, by the gamut mapping of CSS Color 4: a binary search on its chroma, which takes the clipped colour once it's within a ΔEOK of 0.02.

The colour `x` in the gamut of the `space`, by default sRGB, at the same
OKLCH lightness and hue, by the gamut mapping of CSS Color 4: a binary
search on its chroma, which takes the clipped colour once it's within a
ΔEOK of 0.02.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close