chroma.js
chroma.js copied to clipboard
hsla plain JS object constructor does not take alpha into account
chroma( {r:255, g:45, b:33, a:0.5} ) will work fine. We can see the alpha channel properly set in the chroma object and chroma( {r:255, g:45, b:33, a:0.5} ).alpha() returns 0.5.
BUT
chroma({ h:120, s:0.8, l:0.75, a:0.5}) will not consider the value a:0.5. We can see the alpha channel set to 1 instead of 0.5 in the chroma object and chroma({ h:120, s:1, l:0.75, a:0.5}).alpha() returns 1.
For a quick fix, src/io/hsl/index.js
should be unpacking as 'hsla' like the 'rgba' one in src/io/rgb.index.js
is doing.
I do wonder whether alpha support should be refactored as a general-purpose "add-on" in light of #244: maybe instead of defining RGBA as a separate color space, the code should just say "I know about solid color specifications like RGB and HSL and stuff, and all these solid colors can have an alpha after them".