github color-js/color.js v0.2.0
v0.2.0 - Optional tree-shakeable API!

latest releases: v0.6.0-alpha.1, v0.5.2, v0.5.1...
3 years ago

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 to src/index.js
  • defaults.gamutMapping is now defaults.gamut_mapping and we plan to generally use underscore_case for config options going forward.
  • The color.lightness, color.chroma and color.hue accessors that were previously deprecated are now removed.
  • The legacy Color.space() alias is now removed. Just use Color.Space.get().
  • Removed Color.convert(), see #153
  • Color.inGamut() is now a consistent static version of color.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 use color.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 a defaults.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 do ColorSpace.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

Don't miss a new color.js release

NewReleases is sending notifications on new releases.