maxChromaAt
Returns the maximum in-gamut OKLCH chroma at a given lightness and hue.
import { maxChromaAt } from '@pbroom/color-kit';max-chroma.ts:42function 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
- lightness
number - OKLCH lightness, 0-1.
- hue
number - OKLCH hue in degrees.
- options?
MaxChromaAtOptionsdefault{} - Target gamut and search settings.
Returns
numberChroma in [0, options.maxChroma].
Throws
- When
options.gamutis not'srgb'or'display-p3'.
Example
import { maxChromaAt } from '@pbroom/color-kit';
maxChromaAt(0.6, 250); // → 0.16982421875
maxChromaAt(0.6, 250, { gamut: 'display-p3' }); // → 0.21923828125