@pbroom/color-kit/planeQueries
getPlaneFallbackPoint
Gamut-maps a color into the target gamut and returns where the mapped color lands on the plane.
import { getPlaneFallbackPoint } from '@pbroom/color-kit/plane';fallback-point.ts:46function 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
- planeDefinition
PlaneDefinition - Plane to project onto; a
Planeor anyPlaneDefinition. - query
Omit<PlaneFallbackPointQuery, 'kind'> - The
colorto map and the targetgamut.
Returns
PlaneFallbackPointResultA new result with the gamut and the plane point, including the mapped color.
Throws
- When
gamutis not'srgb'or'display-p3'.
Example
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
@pbroom/color-kitthe same declaration, re-exported