Releases: color-js/color.js
v0.4.1: TypeScript support, legacy builds
The main new feature of this release is Typescript support, added in this Herculean PR by @MysteryBlokHed and reviewed by @jgerigmeyer.
Other new features and changes:
deltaPhi
contrast method now supported, thanks to a PR by @Myndex- Node v12 and somewhat older browsers are now supported, through separate
.legacy
builds, thanks to a PR by @jgerigmeyer - The
premultiplied
option is now supported inmix()
, thanks to a PR by @redneb - Support both number and percent in (ok)lab and (ok)lch lightness. Serialize as number, per spec.
- Lab-D65 is now serialized as
lab-d65()
and notlab()
.
All merged pull requests
- [contrast / deltaPhi] by @Myndex in #209
- Fix missing import by @Myndex in #210
- Add Carbon by @sayzlim in #211
- Fix some typos in contrast docs by @xi in #216
- Contrast docs by @svgeesus in #214
- Add Babel with support for Node v12. by @jgerigmeyer in #215
- Update z-index by @mixalistzikas in #222
- [types] Add type definitions from DefinitelyTyped/DefinitelyTyped#62510 by @MysteryBlokHed in #221
- support the premultiplied option in mix by @redneb in #219
- [spaces] Lab,LCH,Oklab,Oklch lightness is number or percent. Fix #225 by @svgeesus in #227
- [tests] correct an XYZ test, now passes by @svgeesus in #229
New Contributors
- @Myndex made their first contribution in #209
- @sayzlim made their first contribution in #211
- @xi made their first contribution in #216
- @jgerigmeyer made their first contribution in #215
- @mixalistzikas made their first contribution in #222
- @MysteryBlokHed made their first contribution in #221
- @redneb made their first contribution in #219
Full Changelog: v0.4.0...v0.4.1
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
v0.3.0
What's Changed
- The tree-shakeable API is now a lot more tree-shakeable, as side effects have been removed from color space modules, thanks to @sgomes in #184
- Custom output formats (docs
- Breaking change: The
fallback
parameter has been removed fromcolor.toString()
/serialize()
. The functionality has been moved to a separatecolor.display()
/display()
function. See #192 - Don't import Color class in keywords.js by @sgomes in #182
- Several small improvements and bugfixes
Full Changelog: v0.2.4...v0.3.0
v0.2.4
v0.2.3
v0.2.2
Fixed two bugs:
- Fixed regression with the fallback parameter in
serialize()
/color.toString()
- Precision in
serialize()
/color.toString()
now applies to alpha too
Full Changelog: v0.2.1...v0.2.2
v0.2.1
v0.2.0 - Optional tree-shakeable API!
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
v0.1.0 - Candidate public release
Lots of breaking changes in this release, so be careful when upgrading from v0.0.x!
- Major refactor of the API and internals after our experience drafting a Color API for the Web Platform. The main changes are:
- #113 Color spaces are now defined by
ColorSpace
objects with abase
property, which creates a tree of color spaces. Conversions between spaces now use the lowest common ancestor in the tree as a connection space, eliminating the need for custom pre-computed "shortcuts" for conversions - #144 Breaking change: Instead of long-form coordinate names like
hue
,chroma
,lightness
, we now use shorter ones likeh
,c
,l
. The longer names are still there as metadata, which can be useful for generating UIs (such as this generic color picker for any color space! - #111
color.get(coordRef)
,color.getAll(spaceRef)
,color.set(coordRef, coorde)
,color.setAll(spaceRef, coords)
for reading/setting coords in any color space. These are faster, and more flexible. The previous syntax (color.spaceId.coordId
) is still available, but has been moved to a plugin and is not used internally (which should improve performance of a variety of functions). Color.defineSpace()
is nowColorSpace.register()
(with different params)- Due to the way color spaces are now defined, we have added linear versions of every RGB space (and ACEScg which is the linear version of ACEScc)
- #113 Color spaces are now defined by
- #152 Breaking change:
color.toGamut()
now performs in-place modification. Clone the color first if you want the old behavior:color.clone().toGamut()
- #145 Breaking change:
color.spaceId
andcolor.space
are now immutable which helps performance - Breaking change: Trimmed down the API and removed methods that were hardly ever used:
color.getCoords({inGamut, precision})
util.value()
,util.capitalize()
,util.extend()
- Breaking change: #147 Removed
color.hue
,color.chroma
,color.lightness
as well asColor.shortcuts
that defined these. Now the color space for these needs to be explicitly defined. More details on the reasoning in #147. - Breaking change: #148 Default output space for interpolation is now the interpolation space instead of the first color's color space
- CSS-like functional formats are now defined by CSS-like grammars such as
["<number> | <angle>", "<percentage>", "<percentage>"]
- Breaking change:
fallback
parameter incolor.toString()
is now simplified to be either a boolean or a color space reference, no arrays.Color.defaults.fallbackSpaces
is now removed,Color.defaults.css_color
is automatically populated from a predefined list oflab
,rec2020
,p3
,srgb
based on what the current browser supports (orsrgb
if there no browser). - #155 Fixes to make Color.js usable on Node
- Breaking change:
dist/
files renamed (and their.min
versions):dist/color.esm.js
is nowdist/color.js
dist/color.js
is nowdist/color.global.js
dist.color.cjs.js
is nowdist/color.cjs
- Also lots of other bugfixes, test fixes, demo fixes, docs fixes
Full Changelog: v0.0.7...v0.1.0
Tree of color spaces we support