@pbroom/color-kit/planeQueries

getPlaneFallbackPoint

Gamut-maps a color into the target gamut and returns where the mapped color lands on the plane.

functionimport { getPlaneFallbackPoint } from '@pbroom/color-kit/plane';fallback-point.ts:46
function getPlaneFallbackPoint(
  planeDefinition: PlaneDefinition,
  query: Omit<PlaneFallbackPointQuery, 'kind'>,
): PlaneFallbackPointResult;

Uses the default mapping of toSrgbGamut / toP3Gamut (OKLCH chroma reduction). Useful for marking the in-gamut fallback of an out-of-gamut selection. A non-finite (powerless) hue on the input is treated as 0. The point is clamped to the plane window.

Parameters

planeDefinitionPlaneDefinition
Plane to project onto; a Plane or any PlaneDefinition.
queryOmit<PlaneFallbackPointQuery, 'kind'>
The color to map and the target gamut.

Returns

PlaneFallbackPointResultA new result with the gamut and the plane point, including the mapped color.

Throws

  • When gamut is not 'srgb' or 'display-p3'.

Example

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

const plane = definePlane({ fixed: { h: 264 } });
const { point } = getPlaneFallbackPoint(plane, {
  color: parse('oklch(0.7 0.3 264)'),
  gamut: 'srgb',
});
point.x; // → 0.7
point.y.toFixed(3); // → '0.609'
toHex(point.color); // → '#6c9aff'

See also

sense for the fluent form.

Also exported from