Releases: gilbarbara/colorizr
5.0.1
Internals
- Normalized color space matrices — Renamed and reshaped all conversion constants to standard
number[][]format. FixedLSMtypo →LMS. Made implicit coefficients explicit inOKLAB_TO_CLMS. - Fixed
LMS_TO_LRGBprecision — Updated to Bjorn Ottosson's published M1-inverse values (previously off by ~1e-8). - Extracted gamma functions —
srgbGammaDecode/srgbGammaEncodeextracted from inlined copies in converters and luminance.
New Exports
- Conversion matrices —
LRGB_TO_LMS,LMS_TO_LRGB,OKLAB_TO_CLMS,CLMS_TO_OKLAB,SRGB_TO_P3,P3_TO_SRGB,P3_TO_XYZ,XYZ_TO_SRGB - Scalars —
DEG2RAD,RAD2DEG,GAMUT_EPSILON,PRECISION - Functions —
srgbGammaDecode,srgbGammaEncode,isInGamut,oklabToLinearSRGB,oklabToLinearP3
Docs
- New Constants and Helpers pages under an "Exports" section
- New recipe: Build a P3-aware HSV color picker
Commits
5.0.0
This release aligns colorizr with the CSS Color Level 4 specification. Internal color math now operates at full float precision, converters produce spec-compliant values, and new perceptually uniform tools — gamut mapping, Delta E, and configurable interpolation spaces — make the library suitable for modern color workflows.
The API surface has been cleaned up to reflect this shift: naming is more consistent, key functions accept shorthand parameters, and legacy utilities that didn't fit the new model have been removed.
Removed
readableColorAPCA— Function andReadableColorAPCAOptionstype removed.hexadecimalToNumber— No longer exported.Colors— Type removed.
Renamed
| Before | After |
|---|---|
convert(input, format) |
convertCSS(input, format) |
getOkLCHMaxChroma(input, precision) |
getP3MaxChroma(input, precision) |
Changed Signatures
scheme
The type option has been renamed to scheme:
// Before
scheme('#f00', { type: 'analogous' })
// After
scheme('#f00', { scheme: 'analogous' })palette
Now accepts a format shorthand. The type: 'monochromatic' option is replaced by a monochromatic boolean:
// Before
palette('#f00', { type: 'monochromatic', format: 'hsl' })
// After
palette('#f00', { monochromatic: true, format: 'hsl' })
// Shorthand
palette('#f00', 'hsl')mix
The fourth parameter now accepts a MixOptions object with format, hue mode, and interpolation space:
// Before
mix('#f00', '#00f', 0.5, 'hsl')
// After
mix('#f00', '#00f', 0.5, 'hsl') // shorthand still works
mix('#f00', '#00f', 0.5, { space: 'oklab', hue: 'longer' }) // new optionsformatCSS
Second parameter now accepts a format shorthand. Output format auto-detects from the input model instead of defaulting to hex:
// Before
formatCSS({ h: 0, s: 100, l: 50 }, { format: 'hsl' })
// After
formatCSS({ h: 0, s: 100, l: 50 }) // auto-detects "hsl"
formatCSS({ h: 0, s: 100, l: 50 }, 'rgb') // shorthandformatHex
Now accepts strings without the # prefix:
formatHex('ff0000') // → '#ff0000'Precision Changes
Converters now return full float precision internally. CSS string output uses 5 significant digits, matching the CSS Color Level 4 recommendation. This changes numeric output values across most conversion and manipulation functions.
New
deltaE(color1, color2)— Perceptual color difference using Delta E OK. IncludesDELTA_E_JNDconstant.toGamut(input, format?)— Map an out-of-gamut color into sRGB by reducing OkLCH chroma.Colorizr.deltaE(input)/Colorizr.toGamut(format?)— Class methods for the above.MixOptions/HueMode/ColorValuetypes.
Changelog
- Upgrade dependencies: cc637a7
- Refactor color conversion precision to match CSS Color Level 4: 6067422
- Add "delta-e" function: b0f354f
- Add "toGamut" function: 7f6a80c
- Update "mix" interpolation space and hue mode: 4a91cae
- Add internal ParsedColor to eliminate redundant parsing: 32fcd8c
- Consolidate alpha channel handling: 086d549
- Rename getOkLCHMaxChroma to getP3MaxChroma: 03bbe68
- Replace "type" with "monochromatic" boolean in "palette": d95a894
- Update formatHex to accept strings without #: bc4782f
- Update scheme parameters: 3053b5b
- Rename convert to convertCSS: db62265
- Fix transparentize and opacify default format to match the input: d62faef
- Minor fixes: cd3c537
- Update tests to use test.each object pattern: 1565997
- Fix formatCSS output format auto-detection and alpha: b16bd46
- Add shorthand parameter to formatCSS, mix and palette: ce0bb16
- Remove readableColorAPCA: 20b1d99
- Update CI workflow: 8cf89fb
- Update README: 0e70a5c
- Remove demo: 84488af
- Add docs website: 8a7fffc
4.0.1
4.0.0
- Add getColorType function to detect CSS color types: bffd0e4
- Refactor isValidColor to support optional color type validation: 2b8a9b5
- Rename getP3Color to getP3MaxColor: bf7af92
- Update "random" API: ae84ced
- Rename "swatch" to "scale": b33e6ed
- Rename textColor to readableColor: c492c99
- Add "grayscale" and "mix" color functions: 6c830a3
- Update parameter validation and error messages: ee71f97
- Fix "palette" hue rotation: 2ed2d06
- Update "rotate" degrees validation to enforce range: bbeb8b9
- Add JSDoc comments for all exported functions: 47c463e
- Update README: 642c5a7
- Update demo: 22d99f8
Breaking changes
- textColor → readableColor
- swatch → scale
- getP3Color → getP3MaxColor
- random(type) → random(options) (use format option)
- removed Alpha, Amount, Degrees type aliases (use number)