@pbroom/color-kitManipulation

invert

Invert a color in OKLCH: lightness becomes 1 - l and the hue rotates 180°, while chroma and alpha are kept. This is a perceptual inversion, not an sRGB channel inversion, and the result is not gamut mapped.

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

Parameters

colorColor
Color to invert

Returns

ColorA new Color

Example

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

invert(parse('oklch(0.3 0.1 30)')); // → { l: 0.7, c: 0.1, h: 210, alpha: 1 }

See also