-
Notifications
You must be signed in to change notification settings - Fork 22.8k
Detail about <number>s in rgb-related color functions and glossary #28962
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
Conversation
Preview URLs
(comment last updated: 2023-09-08 16:44:18) |
I just noticed the "Flaws (1)" indicator. Should I remove the reference to "/en-US/docs/Glossary/GLSL"? |
The CSS Color spec does allow non-integers for these functions, though. For
(Note it's
For
For
|
It's up to you guys if you don't want to document the integer rounding. All the browsers do it. The I've never seen the The docs page for
For these color functions the values are rounded, not floored (truncated). |
IMO it's fine to say that floating point numbers are accepted, as they certainly are, but there should be a clear statement of the fact that they will be rounded, and probably a mention of why/how that works relative to the other color functions/spaces that don't round, i.e. 16.78M colors, hsl and hwb converted to rgb, etc. Also note that for better or worse, this PR has a couple of other changes that have nothing to do with the rounding of numbers. See the change to the |
After further checking 15.2. Serializing sRGB values from the spec (emphasis mine):
…the linked WPT test (especially the "Property color value 'rgb(2.5, 3.4, 4.6)' [Tests that RGB channels are rounded appropriately]" test), and w3c/csswg-drafts#1983, I think it is more future-proof to avoid stating that implementations limit the number of sRGB colors to an explicit quantity. To make the edits less intrusive, a note could be added at the end of the "Values" section on each of
E.g. The datails of how rounding of |
Co-authored-by: yarusome <97945148+yarusome@users.noreply.github.com>
Co-authored-by: yarusome <97945148+yarusome@users.noreply.github.com>
Co-authored-by: yarusome <97945148+yarusome@users.noreply.github.com>
I have committed all your review changes. Please let me know if there is anything else I can/should do to complete this PR. I assumed that your review comments required no further action, sorry if that was incorrect. These two suggestions from your last comment are still outstanding:
|
Markup here removed key parts of that quote;
I am not a graphic artist or color expert, I'm a programmer. My perspective on this is limited, and tainted by this blog post: https://developer.chrome.com/articles/high-definition-css-color-guide/, in that I see the rgb, hsl, and hwb functions as low-definition and the rest of the color functions as high-definition. The integer rounding fits into this perspective, as wrong as it might be relative to the spec. |
I made your first pending suggested change and pushed the changes. I know I saw the section you refer to in your second pending suggestion, but I can't find it now. This is your suggestion, where is the text that discusses rounding in animations?
|
See this codepen: https://codepen.io/sidewayss/pen/qBLqPPa
rgb()
function, so there's no point in using them.hsl()
andhwb()
are converted torgb
by the browser and are limited to integer values inrgb()
, although achieving whole number changes inrgb()
can require fractional changes in the other two functions.I did not mention 2) in either the
hsl
orhwb
page, though I took a crack at it in the RGB glossary page. I am also not familiar with the various RGB color spaces, but in the CSScolor()
function, the Adobea98-rgb
color space is represented by a "fractional value" (aka unit interval) between 0 and 1. Not sure how that fits in with this paragraph in the RGB glossary page:I just committed some edits to the
color()
function page. CSS needs a more generic type for "number between 0 and 1", or does it exist and I'm unaware of it?<alpha-value>
is identical to what is needed, but it is specified as belonging to the alpha value, notopacity
or any of the other properties/functions that take a number between 0 and 1 or a<percentage>
.