Experimenting in Chrome indicates that rgba()
colors are interpreted as non-premultiplied alpha. (I haven't tried #RRGGBBAA
colors as they are not supported by default by Chrome.)
Is there an official spec about this?
If CSS were to be using pre-multiplied alpha, that would mean e.g. rgb(255, 0, 0)
at 50% opacity would have to be rgba(127.5, 0, 0, 0.5)
. And rgba(255, 0, 0, 0.5)
would be invalid.
The latest version of the spec mentions for rgb
and rgba
:
The first three arguments specify the red, green, and blue channels of the color, respectively. 0% represents the minimum value for that color channel in the sRGB gamut, and 100% represents the maximum value. A is equivalent to a , but with a different range: 0 again represents the minimum value for the color channel, but 255 represents the maximum.
This defines non-premultiplied values. If values were, or could be, pre-multiplied this would've had to say something about the maximum value depending on the alpha-value.
The CSS3 spec k2snowman69 links to isn't as specific but likewise doesn't mention anything about RGB values depending on the alpha value and includes examples that would be invalid if they were pre-multiplied.
I don't think APIs ever use pre-multiplied alpha, unless those APIs are expected to be able to deal with image data that has already been partially processed in some way, such as in image processing libraries. Pre-multiplying the alpha channel is something that's done to simplify the color blending calculations. It's not really something that helps end-users.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With