lightnessScale
Generate a dark-to-light scale at the hue and chroma of color: steps colors with OKLCH lightness evenly spaced from range[0] to range[1] (both included). Chroma, hue and alpha are copied unchanged, so stops near the ends can fall outside the sRGB gamut; they are not gamut mapped.
import { lightnessScale } from '@pbroom/color-kit';index.ts:155function lightnessScale(
color: Color,
steps?: number,
range?: [number, number],
): Color[];Parameters
- steps?
numberdefault11 - Number of stops in the scale (default
11, minimum2) - range?
[number, number] - Lightness range
[min, max](default[0.05, 0.95])
Returns
Color[]steps new Colors
Throws
- When
stepsis less than 2
Example
import { lightnessScale, parse } from '@pbroom/color-kit';
lightnessScale(parse('oklch(0.6 0.1 250)'), 3, [0.2, 0.8]).map((c) => c.l);
// → [0.2, 0.5, 0.8]