moonrgbacolour for MoonBit

The gamut

Where the colour stops.

sRGB is a shape inside Oklch, not a box. At any one lightness it is a closed curve: everything inside can be shown on an ordinary screen, everything outside cannot. This page draws that curve from the library, and moves a point into it the way Color::to_gamut does.

OkLCh slicesRGBCSS Color 4 §13.2

the colour asked for what the library returns chroma, held at this lightness and hue
state
outside sRGB
moved
0.1945
lightness
0.7000
chroma
0.4000
hue
30.00
edge here
0.1915
0.700
0.400
30°

ΔE OK from the clipped colour, along the line

Below the 0.02 mark, clipping is close enough to the colour asked for that the search stops there.

#ff5843 oklch(0.6831 0.2062 30.18163)
01

How it decides

Four steps, and the fourth is the one that surprises people.

  1. Ask whether it fits. A colour inside the target gamut comes back unchanged.
  2. Hold lightness and hue, and halve the chroma. The interval between a chroma that fits and one that does not is cut in half until the answer is as precise as the arithmetic allows — twenty-two times, which is further than the eye can see.
  3. Compare with what clipping would give. At each candidate, the colour is also clipped, and the two are measured with ΔE OK. Under 0.02 — about the smallest step an eye notices — the candidate is close enough, and the search keeps the chroma it has rather than shrinking further.
  4. Fall back to clipping when nothing passes. A colour too light or too dark to exist at any chroma cannot be reached by lowering chroma at all, so the clipped colour is the answer, and it may have moved in lightness and hue. That is why the square on the plot is not always on the line.

The surface is not a gradient. It is six rings of 180 colours each, computed by the library at this lightness — 1,080 conversions per redraw, which is why the plot changes when you move the lightness slider and not while you drag the hue.

Read the other way round, the shape is the answer to a question: at this lightness, no colour with more chroma than the edge exists on an sRGB screen, whatever its hue.