github color-js/color.js v0.4.0
v0.4.0: All about contrast! 🔳🔲

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

The most major change in this release is new contrast methods! Until v0.3.0, Color.js only supported WCAG 2.1 contrast, which has several known problems. In this release, @svgeesus implemented four more contrast methods, and wrote all about them. There are both specific methods you can use (e.g. background.contrastAPCA(foreground) / with the OO API and contrastAPCA(background, foreground) with the procedural API as well as a generic contrast() method that accepts a parameter for the contrast algorithm (e.g. color.contrast(color2, "Weber") with the OO API or contrast(color, color2, "Weber") with the procedural API).

Breaking change: color.contrast() / contrast() will now not work without an explicit contrast algorithm, which is on par with the recent changes in CSS Color's contrast-color() function. If you try to use it without an algorithm, it will produce a TypeError listing all supported contrast algorithms.

image

Demo: To celebrate this addition, we've added a new demo app that calculates if white or black produces higher contrast over a variety of colors with the contrast algorithm you select!

image

Other changes

  • The deltaE() function now imports all deltaE methods. If you need a more tree-shakable deltaE API, import the individual methods directly.
  • The method argument in deltaE() is now case-insensitive
  • The chromaticity module has been fixed to work correctly with the procedural API

Merged Pull requests

New Contributors

Full Changelog: v0.3.0...v0.4.0

Don't miss a new color.js release

NewReleases is sending notifications on new releases.