While we were hoping that the previous release would be the last one done before Color.js is "officially" released in the wild, we ended up making some more big changes before this happens, but for a very good reason.
The biggest change in this release is that all internals have been rewritten to provide an alternative API that is procedural and thus, tree-shakable. It is also faster because it can operate on plain objects instead of Color
objects. You can read more about how this works in the docs. Color spaces are still not tree-shakeable, see #163.
If you prefer the OO API, you can continue using it, it is not going anywhere!
Other breaking changes
Leanness has been a focus of this release, so we removed a lot of cruft that did not make sense or was superfluous.
src/main.js
has been renamed tosrc/index.js
defaults.gamutMapping
is nowdefaults.gamut_mapping
and we plan to generally use underscore_case for config options going forward.- The
color.lightness
,color.chroma
andcolor.hue
accessors that were previously deprecated are now removed. - The legacy
Color.space()
alias is now removed. Just useColor.Space.get()
. - Removed
Color.convert()
, see #153 Color.inGamut()
is now a consistent static version ofcolor.inGamut()
. Previously it had an entirely different signature.new Color("--foo" [, element])
syntax has been removed, see #160 for details.new Color(coords [,alpha])
signature which assumed sRGB has been removed. Just provide the color space explicitly.color.white
getter has been removed. Just usecolor.space.white
.- The fallback parameter in
color.toString()
/serialize()
has been simplified to take a single color space instead of an array. Similarly,defaults.fallbackSpaces
has been removed, there is now only adefaults.css_space
that is set upon startup and can be overridden.
Other changes and fixes
- New
ColorSpace#to(color)
signature - New
ColorSpace#from(space, coords)
/ColorSpace#from(color)
method b130d02 ColorSpace.get()
now accepts alternatives, e.g. you can doColorSpace.get("oklch", "lch")
to get oklch if available, or lch otherwise.- Fixed ACEScc range #157
Acknowledgements
We'd like to thank @ai for his help and encouragement wrt making Color.js tree-shakeable! (#159)
Full Changelog: v0.1.0...v0.2.0