Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

v3.0.0 #192

Feb 23, 2023 · 2 comments · 3 replies
Discussion options

Breaking changes

This new release includes revamped color parsing to align with the latest css-color-4 spec. Regular expression matching has been replaced with a parser that follows the css-syntax spec more closely.

The new parser is more flexible with some aspects and stricter with others:

Interpretation of component values has been aligned to the spec:

  • in non-legacy syntaxes, percentages are mapped to a reference range for that component. For example, the range of lch.c (Chroma in the CIELCh color space) is [0, 150], with 100% corresponding to 150.

Serialization has also been aligned to the spec:

  • lab and lch serialize the L component as <number>, not <percentage>
  • oklab‌, oklch and lrgb are serialized to oklab(), oklch(), and color(srgb-linear) respectively.

Please consult the migration guide for assistance in upgrading from 2.x to 3.0.

API changes

  • parseRgb and parseHsl now perform parsing of the modern syntax for rgb() and hsl() respectively;
  • parseRgbLegacy and parseHslLegacy have been added to parse the legacy syntaxes for rgb() / rgba() / hsl() / hsla()
  • parseOklab and parseOklch have been added to parse oklab() and oklch().

This discussion was created from the release v3.0.0.
You must be logged in to vote

Replies: 2 comments 3 replies

Comment options

This is great! Will there be a feature for explicitly accessing a single channel from a color object similar to Chroma.js chroma(color).get('lch.l) which returns the specified channel's value.

You must be logged in to vote
3 replies
Comment options

danburzo Feb 25, 2023
Maintainer Author

Thanks, @prjctimg! In general we've left nice-to-have abstractions to userland code, when they're not hard to implement. A function like the one you mention could be achieved with:

function get(color, component) {
 const [mode, channel] = component.split('.');
 return culori.converter(mode)(color)?.[channel];
}
get('tomato', 'lch.l');
// => 62.99090584103958 

This would probably go in a recipes section on the website.

Comment options

Awesome! I'll be sure to check up on the API as of v3. Had used Culori side by side with chroma-js because I couldn't implement some of the functionalities I required myself.

I'm working on a smallish library that does all sorts of tricks with color. Its still in the infancy stage. I'm using Culori as the core dependancy for the functionalities. I'm still migrating from Chroma.js in favor of a more functional approach to the codebase.

Please take a peek at https://github.com/prjctimg/huetiful

Comment options

danburzo Feb 25, 2023
Maintainer Author

Very cool! Good luck with the rewrite! :-)

Comment options

thanks so much for your relentless work!

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /