@pbroom/color-kit/planeMapping
planeToColor
Converts a normalized plane point into the color it represents.
import { planeToColor } from '@pbroom/color-kit/plane';mapping.ts:110function planeToColor( resolvedPlane: Plane, , point: PlanePoint,): Color;x and y are clamped to [0, 1] and mapped linearly onto the plane's axis ranges; every other channel comes from resolvedPlane.fixed. The result is an OKLCH Color and is not gamut-mapped.
Parameters
- resolvedPlane
Plane - Plane from
definePlane. - point
PlanePoint - Normalized plane point (
x,yin[0, 1]).
Returns
ColorA new color for that point.
Example
import { toHex } from '@pbroom/color-kit';
import { definePlane, planeToColor } from '@pbroom/color-kit/plane';
const plane = definePlane({ fixed: { h: 264 } }); // x: l, y: c in [0.4, 0]
const color = planeToColor(plane, { x: 0.6, y: 0.75 });
// → { l: 0.6, c: ≈ 0.1, h: 264, alpha: 1 }
toHex(color); // → '#617fbc'See also
colorToPlanefor the inverse.colorAtPlanePointto pass an unresolved definition.
Also exported from
@pbroom/color-kitthe same declaration, re-exported