-
Notifications
You must be signed in to change notification settings - Fork 708
[css-color-4] Computed/used value of color doesn't specify how to serialize. #1891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Agree this should be specified. Integer format is historically more popular, but it also assumes an 8 bit per component model. The introduction of wide gamut displays means that higher bit depths are becoming more common. Canvas is also shifting to allow more bits per component. Thus, CSS Color 4 is tending to prefer a bit-depth agnostic 0 to 1 (or for rgb, 0% to 100%) I would prefer to see the % notation. The introduction of wider RGB spaces, ICC colors, Lab, LCH also means that computed and used values, and serialized values, need to be specified there too. |
The rgb() numeric args are numbers now, not ints, so they can handle any bit depth with no problem. Since impls have historically serialized with the number syntax, we should probably preserve that in the serialization rules. |
Agreed. Lets clarify in the spec that the |
I agree with Tab, it is better to standardize on rgb with arbitrary precision numbers, since this simplifies to integers if the input is rgb integers or hex codes (maintaining compat), while still allowing for higher precision value or values beyond the sRGB gamut if the specified value uses a different format. |
The change from ints to numbers in It also directly contradicts CSSOM, which is now fine as we resolved today to remove the serailization of RGB from CSSOM and consolidate it all into CSS Color 4; so that text can now have the precision test built in.
Given the conflict with what CSSOM used to say, this needs tests too. |
Examples have now been added to the spec, serialising for all the sRGB-based ones to `rgb( )' with suppression of trailing zeroes, and of trailing decimal if all the fractional part is zero, and suppression of fully opaque alpha, and no commas. Not sure about the commas though for compat. |
The section "Resolving Color values" in CSS Colors 4 makes it explicit that computed & used values for color should use
rgb
orrgba
notation.But it doesn't say whether to use the (0-255) format or percentages. Quick test suggest that integer format is preferred by browsers.
On high-color-depth monitors, converting all colors to integers could mean a loss of data, if the numbers were always rounded off to a nearest integer. But since the latest specs allow decimals in the 0-255 syntax, maybe the rounding could be left as implementation-dependent?
The text was updated successfully, but these errors were encountered: