oklch-math
v0.0.1
Published
Small, strict OKLCH primitives for color systems and tooling.
Maintainers
Readme
OKLCH Math
Small, strict OKLCH primitives for color systems and tooling.
oklch-math keeps the smallest useful pieces of an OKLCH workflow in one dependency-free package: validation, hue normalization, parsing, formatting, and channel updates.
Not published yet. It builds from source in this repository.
Usage
import { formatOklch, parseOklch, updateOklch } from "oklch-math";
const blue = parseOklch("oklch(62% 0.18 250)");
const softer = updateOklch(blue, { chroma: 0.12 });
console.log(formatOklch(softer));API
| Export | Purpose |
| --- | --- |
| validateOklch | Validate and normalize an OKLCH color. |
| normalizeHue | Wrap a hue into the 0–360 range. |
| parseOklch / formatOklch | Convert between CSS OKLCH strings and objects. |
| updateOklch | Update one or more channels with validation. |
| distance | Measure a compact OKLCH-space distance. |
Development
npm run buildLicense
MIT
