@pbroom/color-kit/planeQueries
runPlaneQuery
Runs one plane query, dispatching on query.kind.
import { runPlaneQuery } from '@pbroom/color-kit/plane';query.ts:87function runPlaneQuery(
planeDefinition: PlaneDefinition,
query: PlaneQuery,
): PlaneQueryResult;Generic entry point behind the per-kind helpers (getPlaneGamutBoundary, getPlaneGamutRegion, getPlaneContrastBoundary, getPlaneContrastRegion, getPlaneChromaBand, getPlaneFallbackPoint, samplePlaneGradient); useful when queries are built as data. The call is stateless: the plane is resolved on every call and nothing is cached (see PlaneQueryCache).
Parameters
- planeDefinition
PlaneDefinition - Plane to query; a
Planeor anyPlaneDefinition. - query
PlaneQuery - Query payload;
kindselects the query type.
Returns
PlaneQueryResultA new result whose kind matches the query's.
Throws
- When
query.gamutis not'srgb'or'display-p3'. - When
query.kindis unknown or the plane or query options are invalid.
Example
import { definePlane, runPlaneQuery } from '@pbroom/color-kit/plane';
const plane = definePlane({ fixed: { h: 264 } }); // OKLCH, x: l, y: c
const result = runPlaneQuery(plane, { kind: 'gamutBoundary', gamut: 'srgb' });
if (result.kind === 'gamutBoundary') {
result.points.length; // → 101
result.points[0]; // → { l: 0, c: 0, x: 0, y: 1 }
}See also
inspectPlaneQuery to also capture a solver trace.
Also exported from
@pbroom/color-kitthe same declaration, re-exported