@pbroom/color-kit/driverColor area
getColorAreaContrastRegionPaths
Outlines the region of the hue plane whose colors meet the contrast threshold against reference (WCAG AA 4.5:1 by default), as one or more paths of area points (y down). Returns [] unless the axes are lightness and chroma (in either orientation).
import { getColorAreaContrastRegionPaths } from '@pbroom/color-kit/driver';color-area.ts:586function getColorAreaContrastRegionPaths(
reference: Color,
hue: number,
axes: ResolvedColorAreaAxes,
options?: ContrastRegionPathOptions,
): ColorAreaContrastRegionPoint[][];Parameters
- hue
number - OKLCH hue of the plane, in degrees.
- options?
ContrastRegionPathOptionsdefault{}
Returns
ColorAreaContrastRegionPoint[][]
Throws
- When
options.gamutis not'srgb'or'display-p3'(for example the removed'p3'spelling).
Example
import { getColorAreaContrastRegionPaths, resolveColorAreaAxes } from '@pbroom/color-kit/driver';
const white = { l: 1, c: 0, h: 0, alpha: 1 };
const paths = getColorAreaContrastRegionPaths(white, 250, resolveColorAreaAxes(), { level: 'AA' });
paths.length; // → 1
paths[0].length; // → 57