chromaBand
Returns a tonal strip of OKLCH colors from black to white at a fixed hue, keeping each step inside the target gamut.
import { chromaBand } from '@pbroom/color-kit';chroma-band.ts:50function chromaBand(
hue: number,
requestedChroma: number,
options?: ChromaBandOptions,
): Color[];'clamped'(default): userequestedChromawhere the gamut allows it, otherwise the boundary chroma at that lightness.'proportional': take the ratio ofrequestedChromato the boundary chroma atselectedLightness(capped at 1) and apply it to the boundary chroma at every step.
Uniform sampling returns steps + 1 colors; adaptive sampling follows gamutBoundaryPath and, in clamped mode, adds a color where the boundary crosses requestedChroma. Every color carries the normalized hue and options.alpha.
Parameters
- hue
number - OKLCH hue in degrees.
- requestedChroma
number - Desired OKLCH chroma (negative values act as 0).
- options?
ChromaBandOptionsdefault{} - Mode, sampling, gamut and search options.
Returns
Color[]Colors ordered by increasing lightness.
Throws
- When
options.gamutis not'srgb'or'display-p3'. - When
requestedChromais not finite,modeorsamplingModeis unknown, orstepsis not an integer >= 2 (uniform mode).
Example
import { chromaBand } from '@pbroom/color-kit';
chromaBand(250, 0.1, { steps: 4 }).map((color) => color.c);
// → [0, 0.070703125, 0.1, 0.1, 0]