v0.4.0: All about contrast! 馃敵馃敳
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.
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!
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
- Don't import Color class in keywords.js by @sgomes in #182
- [picker-mavo] First pass in fixing the known issues by @DmitrySharabin in #186
- Remove side-effects from spaces by @sgomes in #184
- Spelling by @jsoref in #191
- [parse] Trim input, fixes #196 by @AlainGourves in #197
- [contrast] Add contrast methods by @svgeesus in #194
New Contributors
- @DmitrySharabin made their first contribution in #186
- @jsoref made their first contribution in #191
- @AlainGourves made their first contribution in #197
Full Changelog: v0.3.0...v0.4.0