@pbroom/color-kit/reactPlane geometry
useFallbackPoints
Positions of the plane color after gamut mapping into sRGB and into Display P3, e.g. to mark where an out-of-gamut pick will actually render.
import { useFallbackPoints } from '@pbroom/color-kit/react';use-fallback-points.ts:49function useFallbackPoints(
plane: ColorPlaneSpec,
): ColorPlaneFallbackPoints;Each point carries the mapped color and its normalized x/y (y down) on the plane; for an in-gamut color both coincide with the color's own position. Memoized on the color and axes.
Parameters
- plane
ColorPlaneSpec - Color and axes of the plane.
Returns
ColorPlaneFallbackPointsThe sRGB and Display P3 ColorAreaFallbackPoints.
Throws
- When both axes use the same channel.
Example
import { toHex } from '@pbroom/color-kit';
import { useFallbackPoints } from '@pbroom/color-kit/react';
import type { Color } from '@pbroom/color-kit';
export function SrgbMarker({ color }: { color: Color }) {
const { srgb } = useFallbackPoints({ color });
return (
<span
style={{
position: 'absolute',
left: `${srgb.x * 100}%`,
top: `${srgb.y * 100}%`,
background: toHex(srgb.color),
}}
/>
);
}