@pbroom/color-kit/planeQueries

getPlaneContrastBoundary

Traces where colors at one hue cross a contrast threshold against a reference color, projected onto the plane.

functionimport { getPlaneContrastBoundary } from '@pbroom/color-kit/plane';contrast-boundary.ts:61
function getPlaneContrastBoundary(
  planeDefinition: PlaneDefinition,
  query: PlaneContrastQueryOptions,
  trace?: InternalPlaneTraceContext | null,
): PlaneContrastBoundaryResult;

Returns the longest contour line that getPlaneContrastRegion finds, as a single point list (each point carries OKLCH l/c and plane x/y). Use getPlaneContrastRegion() to get every line, for example both the darker and the lighter side of a mid-tone reference.

Only OKLCH lightness × chroma planes produce geometry (see usesLightnessAndChroma); any other plane returns an empty list, after the same option validation.

Parameters

planeDefinitionPlaneDefinition
Plane to project onto; a Plane or any PlaneDefinition.
queryPlaneContrastQueryOptions
Contrast options: reference color, optional hue override, and the metric, threshold and sampling options of ContrastRegionPathOptions (WCAG 'AA' against sRGB by default).
trace?InternalPlaneTraceContext | null
Internal trace hook; leave it out and use inspectPlaneQuery to capture a trace.

Returns

PlaneContrastBoundaryResultA new result with the resolved hue and contour points.

Throws

  • When gamut is not 'srgb' or 'display-p3', or an option removed with an earlier solver (such as lightnessSteps) is set.
  • When the threshold or a sampling option is out of range.

Example

TypeScript
import { parse } from '@pbroom/color-kit';
import { definePlane, getPlaneContrastBoundary } from '@pbroom/color-kit/plane';

const plane = definePlane({ fixed: { h: 264 } });
const { points } = getPlaneContrastBoundary(plane, {
  reference: parse('#ffffff'),
  level: 'AA',
});
points.length; // → 53
points[0].l.toFixed(3); // → '0.568'

See also

sense for the fluent form.

Also exported from