@pbroom/color-kit/planeQueries
getPlaneContrastBoundary
Traces where colors at one hue cross a contrast threshold against a reference color, projected onto the plane.
import { getPlaneContrastBoundary } from '@pbroom/color-kit/plane';contrast-boundary.ts:61function 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
- planeDefinition
PlaneDefinition - Plane to project onto; a
Planeor anyPlaneDefinition. - query
PlaneContrastQueryOptions - Contrast options:
referencecolor, optionalhueoverride, and the metric, threshold and sampling options ofContrastRegionPathOptions(WCAG'AA'against sRGB by default). - trace?
InternalPlaneTraceContext | null - Internal trace hook; leave it out and use
inspectPlaneQueryto capture a trace.
Returns
PlaneContrastBoundaryResultA new result with the resolved hue and contour points.
Throws
- When
gamutis not'srgb'or'display-p3', or an option removed with an earlier solver (such aslightnessSteps) is set. - When the threshold or a sampling option is out of range.
Example
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
@pbroom/color-kitthe same declaration, re-exported