@pbroom/color-kitConversion

linearRgbToOklab

Convert linear-light sRGB to OKLab.

functionimport { linearRgbToOklab } from '@pbroom/color-kit';oklab.ts:81
function linearRgbToOklab(  rgb: LinearRgb,): Oklab;

Based on Björn Ottosson's OKLab model, using the CSS Color 4 matrices recalculated in float64 for a consistent D65 reference white (bottosson.github.io/posts/oklab/). Inputs are not clamped, so out-of-gamut linear values convert exactly.

Parameters

rgbLinearRgb
Linear-light sRGB color

Returns

OklabA new Oklab

Example

TypeScript
import { linearRgbToOklab } from '@pbroom/color-kit';

linearRgbToOklab({ r: 1, g: 0, b: 0, alpha: 1 });
// → ≈ { L: 0.628, a: 0.2249, b: 0.1258, alpha: 1 }

See also