@pbroom/color-kit/planeQueries

runPlaneQuery

Runs one plane query, dispatching on query.kind.

functionimport { runPlaneQuery } from '@pbroom/color-kit/plane';query.ts:87
function 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

queryPlaneQuery
Query payload; kind selects the query type.

Returns

PlaneQueryResultA new result whose kind matches the query's.

Throws

  • When query.gamut is not 'srgb' or 'display-p3'.
  • When query.kind is unknown or the plane or query options are invalid.

Example

TypeScript
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