API

@pbroom/color-kit/plane

Define 2D color planes and query their gamut and contrast regions, boundaries and paths.

94 exports41 values53 types

@pbroom/color-kit/plane turns color questions into geometry. A plane fixes every channel of a color model but two and maps those two to normalized x and y. Queries against it return points and paths you can draw, hit-test or cache. It powers the React plane hooks' overlays, but nothing in it depends on a UI.

Domains

hit-test.ts
import { parse } from '@pbroom/color-kit';
import {
  colorToPlane,
  containsPoint,
  definePlane,
  sense,
} from '@pbroom/color-kit/plane';

const plane = definePlane({ fixed: { h: 290 } }); // OKLCH lightness × chroma
const srgb = sense(plane).gamutRegion({ gamut: 'srgb' });
const brand = parse('oklch(0.62 0.24 290)');

colorToPlane(plane, brand); // → { x: 0.62, y: ≈ 0.4 }
containsPoint(srgb.visibleRegion, colorToPlane(plane, brand)); // → false

See Planes and queries for the model.

Gamut

Mapping

Compile

Models

Queries

Operations

Types

Tracing