@pbroom/color-kit/planeMapping
planeHue
Resolves the OKLCH hue angle a plane query runs at.
import { planeHue } from '@pbroom/color-kit/plane';mapping.ts:241function planeHue( resolvedPlane: Plane, , hue?: number,): number;Resolution order: the explicit hue override, then the fixed h of an OKLCH plane, then the OKLCH hue of the color made from the plane's fixed channels. On hsl, hsv and hct planes the fixed h is in the model's own hue space, so it is converted rather than returned as is (HSL red, h: 0, resolves to OKLCH ≈ 29.2). When that fixed color is achromatic (the default s: 0 / c: 0), the hue comes from the most saturated color of the model hue instead: s 100 / l 50 (HSL), s 100 / v 100 (HSV) or the HCT peak-chroma tone.
Parameters
- resolvedPlane
Plane - Plane from
definePlane. - hue?
number - Optional explicit OKLCH hue override in degrees; ignored unless finite.
Returns
numberOKLCH hue in degrees, wrapped into [0, 360).
Example
import { parse } from '@pbroom/color-kit';
import { definePlane, definePlaneFromColor, planeHue } from '@pbroom/color-kit/plane';
planeHue(definePlane({ fixed: { h: 264 } })); // → 264
planeHue(definePlane({ fixed: { h: 264 } }), -30); // → 330
planeHue(definePlaneFromColor(parse('#7c3aed'), { model: 'rgb' }));
// → ≈ 293.0 (OKLCH hue of the fixed color)
planeHue(definePlane({ model: 'hsl', fixed: { h: 0 } }));
// → ≈ 29.2 (OKLCH hue of HSL red, not the HSL hue 0)Also exported from
@pbroom/color-kitthe same declaration, re-exported