@pbroom/color-kit/planeMapping

colorToPlane

Projects a color onto a plane, returning its normalized coordinates.

functionimport { colorToPlane } from '@pbroom/color-kit/plane';mapping.ts:147
function colorToPlane(  resolvedPlane: Plane, ,  color: Color,): PlanePoint;

The color is converted into the plane's model, then each axis channel is normalized against its range and clamped to [0, 1], so colors outside the plane window land on its edge. Channels not on an axis are ignored.

Parameters

colorColor
Color to project.

Returns

PlanePointA new normalized point (x, y in [0, 1]).

Example

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

const plane = definePlane({ fixed: { h: 264 } }); // x: l, y: c in [0.4, 0]
colorToPlane(plane, { l: 0.6, c: 0.1, h: 264, alpha: 1 });
// → { x: 0.6, y: ≈ 0.75 }
colorToPlane(plane, { l: 1.2, c: 0.5, h: 264, alpha: 1 }); // → { x: 1, y: 0 }

See also

planeToColor for the inverse.

Also exported from