@pbroom/color-kitGamut

inSrgbGamut

Returns whether an OKLCH color is inside the sRGB gamut.

functionimport { inSrgbGamut } from '@pbroom/color-kit';membership.ts:115
function inSrgbGamut(color: Color): boolean;

Tests the unclamped linear sRGB channels with isLinearRgbInGamut (so clamping in toRgb cannot produce a false positive), allowing GAMUT_EPSILON of slack on the encoded channels. Allocation-free.

Parameters

Returns

boolean

Example

TypeScript
import { inSrgbGamut } from '@pbroom/color-kit';

inSrgbGamut({ l: 0.7, c: 0.1, h: 150, alpha: 1 }); // → true
inSrgbGamut({ l: 0.7, c: 0.2, h: 150, alpha: 1 }); // → false

See also