@pbroom/color-kit/planeMapping
colorToPlane
Projects a color onto a plane, returning its normalized coordinates.
import { colorToPlane } from '@pbroom/color-kit/plane';mapping.ts:147function 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
- resolvedPlane
Plane - Plane from
definePlane.
Returns
PlanePointA new normalized point (x, y in [0, 1]).
Example
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
@pbroom/color-kitthe same declaration, re-exported