@pbroom/color-kitScale

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.

functionimport { lightnessScale } from '@pbroom/color-kit';index.ts:155
function lightnessScale(
  color: Color,
  steps?: number,
  range?: [number, number],
): Color[];

Parameters

colorColor
Base color (hue, chroma and alpha are preserved)
steps?numberdefault 11
Number of stops in the scale (default 11, minimum 2)
range?[number, number]
Lightness range [min, max] (default [0.05, 0.95])

Returns

Color[]steps new Colors

Throws

  • When steps is less than 2

Example

TypeScript
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]

See also