It’s been a while since our last release, so this is a big one!
Going forwards, we plan to make at least one release per month.
Heads ups
⚠️ Future breaking change
Color.js currently uses NaN
values to represent CSS none
(e.g. for achromatic colors).
However, CSS also now has a NaN
value, which is currently impossible to represent in Color.js.
Therefore, In the next non-minor version, we will start using null
to represent none
.
If you have code that handles these values, you can prepare for the change by detecting which value is being used and using that instead of a hardcoded NaN
:
const NONE_COORD = new Color("rgb(none none none)").coords[0].valueOf()
🆕 Color.js Discord server
We’ve just set up a Discord server so that people can help each other and discuss color science topics in a more immediate way. Join now!.
Do note we also have a Discussions section for more long-form help.
⬇️ 2 million downloads!
We’ve recently passed a big milestone: Color.js was downloaded 2 million times on npm!
New in v0.5.0
New Color Spaces
- CAM16 (JMh) by @facelessuser in #379
- HCT by @facelessuser in #380
- Luv and LCHuv by @lloydk in #391
- HSLuv and HPLuv by @lloydk in #404
Improved compatibility with CSS:
- Moving to a standard
--
-prefixed version for color spaces that are not built-in into CSS. To facilitate "upgrading" color spaces when they later get added to standard CSS, both--
-prefixed and unprefixed versions of all color spaces are also accepted. Implemented by @jgerigmeyer in #407 and #439 - Add support for more angle units (
grad
,rad
andturn
) improving compatibility with CSS, by @kleinfreund in #324 - Add CSS gamut mapping algorithm by @jamesnw in #344 and #352
- Remove gamut mapping from
hsl()
,hwb()
andhsv()
by @jamesnw in #331
Gamut mapping improvements
- Support for HCT gamut mapping by @facelessuser in #420
- toGamut extended to allow configuring the delta E method, the JND, and enabling white and black SDR clamp by @facelessuser in #420
- Allow hsluv to be gamut mapped using the CSS algorithm by @lloydk in #431
- Avoid needless two-step color conversion at the start of gamut mapping by @facelessuser in #426
- Avoid round-trip to/from oklch in CSS mapping method for colors that are in gamut @jgerigmeyer in #455
Color space API improvements:
- Color spaces can now override the heuristically determined color space used to check gamut via a
gamutSpace
parameter. Implemented by @lloydk in #369 - Color spaces can now define a grammar for
color()
format. Implemented by @lloydk in #370 - Support string ids in
colorSpace.equals()
by @LeaVerou in #413 - Make the color space optional in
getAll()
by @LeaVerou in #413
Precision/accuracy improvements
- Calculate more accurate inverse matrices for cat and pre-calc D50 <-> D65 by @facelessuser in #354 and #360
- Update Oklab matrices for better 64 bit conversion by @facelessuser in #357
- More accurate ICtCp matrices by @facelessuser in #365
- [spaces/prophoto] Use 64 bit-accurate conversion matrices by @svgeesus in f750d09
- Fix how small and zero precision is handled by @facelessuser in #416
Performance improvements
Bug Fixes
- Fix hue related mix issues by @facelessuser in #338
- Accept "Lightness" for lab space first channel name by @jgerigmeyer in #348
- Add CJS file to /fn entry and fix legacy builds by @jgerigmeyer in #349
- [spaces/hsl] Better handling of negative saturation on very oog colors by @svgeesus in f20d78a
- Fix
toPrecision()
(was off by one for fractional inputs) by @efergus in #384 - Color serialization now defaults to percentage for lightness across all color spaces, by @LeaVerou in e36e183
- Fix incorrect parsing of Jzazbz percentage values by @lloydk in #392
- Fix Luv lightness coordinate name by @lloydk in #406
- Ensure alpha is a number in
Color
constructor by @lloydk in #400 - Workaround Next.js production bug in
serialize
by @lloydk in #421 - Allow angle values for HCT hue coordinate by @lloydk in #418
- Fix parsing of HSV color space by @lloydk in #430
- Allow number values for HWB w/b coordinates by @lloydk in #464
- Add missing CSS ids for a98rgb-linear, p3-linear, and prophoto-linear spaces for parsing and serialization by @jgerigmeyer in #439
- Consistently allow any color types (string or object) throughout the codebase by @lloydk and @jgerigmeyer in #453, #451, #456, #457, and #461
TypeScript improvements
- Space coord accessors (e.g.
color.oklch.lightness
) will not produce TS errors any more. Quite a lot of effort by @jgerigmeyer to make this possible, in #389 - Fixed typedef for
steps()
andmix()
, by @MysteryBlokHed in #323 - Fixed type def for MixOptions by @jgerigmeyer in #347
- The fact that
toGamut()
also accepts the color space as a string is now part of the TS definition by @manuelmeister in #318 - Re-export some types at the top level by @MysteryBlokHed in #327
- Added
.js
extension to file imports by @MysteryBlokHed in #333 - Added CJS type defs for node16 resolution by @jgerigmeyer in #383
- Add missing overload for
set
by @MysteryBlokHed in #419 - Add JSDoc comments based on website docs by @MysteryBlokHed in #436
- Re-export some types at the top level of
/fn
entrypoint by @jgerigmeyer in #466
Website
- [navigation] Fix menu z-index on the play page by @manuelmeister in #319
- Add core maintainers to website footer by @jgerigmeyer in #422
- Fix "Defined in" API links by @MysteryBlokHed in #423
Apps
- [apps/gamut-mapping] New app to experiment with different gamut mapping algorithms and quickly see how wide a gamut a color requires by @LeaVerou
- [apps/gradient] pin mavo to hotfix app by @clanghout in #359
- [apps/picker] Use correct granularity in number input rather than 1 across all color spaces (by @sidewayss in #330)
- [apps/convert] Up/down arrows to tweak color coordinates by @LeaVerou
- [apps/convert] Pin color spaces to top by @LeaVerou
Linting & Tests
- New JS-first testsuite that eliminates boilerplate and makes writing tests quick, by @LeaVerou (piloting her experimental testing framework htest.dev)
- Fix Jzazbz tests by @facelessuser in #366
- More consistent formatting across the codebase by @jgerigmeyer in #372
- Add more ESLint recommended rules, and enforce them in CI by @jgerigmeyer in #373
- Enforce trailing commas unless
]
or}
is on the same line by @jgerigmeyer in #440 - Port parse test to new JS testsuite by @lloydk in #427
- Add configurable
verbose
setting andwarn
function to allow customizing logging by @jgerigmeyer in #441 - Other testing improvements by @svgeesus
New Contributors
A huge thank you to all of our existing and new contributors. Color.js would not be what it is without you!
- @manuelmeister made their first contribution in #319
- @kleinfreund made their first contribution in #324
- @dom1n1k made their first contribution in #340
- @clanghout made their first contribution in #359
- @efergus made their first contribution in #384
- @sidewayss made their first contribution in #330
Full Changelog: v0.4.5...v0.5.0