@pbroom/color-kitConversion

toOklch

Copy a Color into a new Oklch object. Color already is OKLCH, so channels are copied unchanged (the hue is not normalized).

functionimport { toOklch } from '@pbroom/color-kit';index.ts:359
function toOklch(color: Color): Oklch;

Parameters

colorColor
Color to copy

Returns

OklchA new Oklch with the same channels

Example

TypeScript
import { parse, toOklch } from '@pbroom/color-kit';

toOklch(parse('oklch(0.7 0.15 30)')); // → { l: 0.7, c: 0.15, h: 30, alpha: 1 }

See also