Module color.gamut

Diagnose and handle colors outside the sRGB gamut.

Use inGamut to test target-space coordinates, clip for simple hard clipping, or choose an explicit perceptual mapper for OKLCH colors. Clipping and perceptual mapping are different operations; this module deliberately has no default mapping policy.

Functions

NameDescription
clip(color) Forces finite encoded sRGB components into the representable sRGB range.
clip(color) Forces finite linear-light sRGB components into the representable range.
inGamut(color) Reports whether an encoded sRGB value is directly representable in sRGB.
inGamut(color) Reports whether a linear-light sRGB value is directly representable in sRGB.
mapToLinearSRgbLocalMinde(value) Maps a straight-alpha OKLCH color using Local MINDE.
mapToLinearSRgbLocalMinde(color) Maps an OKLCH color into linear sRGB with the Local MINDE strategy.
mapToLinearSRgbRayTrace(color) Maps an OKLCH color into linear sRGB with the Ray Trace strategy.
mapToLinearSRgbRayTrace(value) Maps a straight-alpha OKLCH color using Ray Trace.
maxChromaInSRgb(lightness, hue) Measures the maximum directly representable OKLCH chroma in sRGB for fixed lightness and hue.

Structs

NameDescription
SRgbChromaLimit Holds a maximum directly representable OKLCH chroma measurement for sRGB.