gka / chroma.js

JavaScript library for all kinds of color manipulations
https://gka.github.io/chroma.js/
Other
10.08k stars 543 forks source link

`transparent` keyword missing #280

Closed markov00 closed 2 weeks ago

markov00 commented 2 years ago

Hi, it seems that the transparent keyword is not a valid chroma value, is not present on the X11 color list but it is a valid keyword in CSS at least https://www.w3.org/TR/css-color-3/#transparent What is the reason behind that missing keyword?

meodai commented 2 years ago

as you said transparent is a keyword not a color-name. The doc sais "it will recognize any named color from the W3CX11 specification".

markov00 commented 2 years ago

as you said transparent is a keyword not a color-name

You are right, I was probably confused by the fact that W3C calls them keywords and not color names: Basic color keywords, Extended color keywords, A <color> is either a keyword (see Recognized color keyword names) or a numerical RGB specification.

I took a look at the X11 color list but seems that the chroma.js use the SVG color list instead, that is derived from that X11 color list but doesn't follow it completely: https://www.w3.org/TR/SVG11/types.html#ColorKeywords (the grey value is an example)

Anyway, what do you think about adding the transparent CSS color keyword into the list of the accepted color names? Do you think is reasonable, for a javascript color library, handling such exception?

frykten commented 2 years ago

Same issue for unset and any keyword... It's quite restrictive to not have those (I'm coming here from another addon that uses chroma as util).

gka commented 2 weeks ago

Late reply, but is the idea to make chroma.valid('transparent') return true?

I'm be inclined to add transparent as special color to the css2rgb method, but not sure about other CSS keywords such as unset, inherit etc.