Skip to content

Constants

All constants are importable from colorizr:

import { LRGB_TO_LMS, DEG2RAD, GAMUT_EPSILON } from 'colorizr';

All matrices are typed as number[][] (3x3). They follow the naming convention SOURCE_TO_DESTINATION.

These matrices implement the OkLab color space conversion, following Bjorn Ottosson’s published values.

ConstantConversion
LRGB_TO_LMSLinear sRGB to LMS
LMS_TO_LRGBLMS to Linear sRGB
OKLAB_TO_CLMSOkLab to LMS cube roots
CLMS_TO_OKLABLMS cube roots to OkLab
ConstantConversion
SRGB_TO_P3sRGB linear to P3 linear
P3_TO_SRGBP3 linear to sRGB linear

Values from the CSS Color Level 4 specification (D65 white point).

ConstantConversion
P3_TO_XYZP3 linear to XYZ D65
XYZ_TO_SRGBXYZ D65 to sRGB linear
ConstantValueDescription
DEG2RADMath.PI / 180Degrees to radians multiplier
RAD2DEG180 / Math.PIRadians to degrees multiplier
GAMUT_EPSILON0.000001Tolerance for gamut boundary checks
PRECISION5Default number of significant digits for CSS output