@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).

functionimport { getColorAreaContrastRegionPaths } from '@pbroom/color-kit/driver';color-area.ts:586
function getColorAreaContrastRegionPaths(
  reference: Color,
  hue: number,
  axes: ResolvedColorAreaAxes,
  options?: ContrastRegionPathOptions,
): ColorAreaContrastRegionPoint[][];

Parameters

referenceColor
Color to measure contrast against, e.g. the background.
huenumber
OKLCH hue of the plane, in degrees.

Returns

ColorAreaContrastRegionPoint[][]

Throws

  • When options.gamut is not 'srgb' or 'display-p3' (for example the removed 'p3' spelling).

Example

TypeScript
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