@pbroom/color-kitGamut

maxChromaAt

Returns the maximum in-gamut OKLCH chroma at a given lightness and hue.

functionimport { maxChromaAt } from '@pbroom/color-kit';max-chroma.ts:42
function maxChromaAt(
  lightness: number,
  hue: number,
  options?: MaxChromaAtOptions,
): number;

This is the geometry primitive used by gamut boundary overlays and model-accurate hue/chroma gradient generation. It bisects chroma between 0 and options.maxChroma and returns the in-gamut end of the final interval, so the true boundary can sit up to options.tolerance higher. Lightness is clamped to [0, 1] (0 and 1 return 0), hue is wrapped, and when maxChroma itself is in gamut it is returned as a cap. Allocation-free.

Parameters

lightnessnumber
OKLCH lightness, 0-1.
huenumber
OKLCH hue in degrees.
options?MaxChromaAtOptionsdefault {}
Target gamut and search settings.

Returns

numberChroma in [0, options.maxChroma].

Throws

  • When options.gamut is not 'srgb' or 'display-p3'.

Example

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

maxChromaAt(0.6, 250); // → 0.16982421875
maxChromaAt(0.6, 250, { gamut: 'display-p3' }); // → 0.21923828125

See also