Setting a color value in Javascript is easy.
But what is the canonical color format across browsers? In other words what is the value of window.getComputedStyle(element).getPropertyValue("color")
or window.getComputedStyle(element).getPropertyValue("background-color")
? As they are strings it is hard to test for a specific color or transparency.
Is there a way in Javascript to turn these values reliably into an array [r-value, g-value, b-value, alpha]
or any other acceptable CSS color value format? Or coerce these in a comparable color format/string? Like a boolean function Color.equal( colorString )
?
(I’ve spend just four days of debugging to find out that "rgb(0 0 0/0)"
is not equal to "rgba(0, 0, 0, 0)"
although semantically they are the same color.)