-
Notifications
You must be signed in to change notification settings - Fork 715
[css-color] Support all existing (non-legacy?) formats in color()? #6741
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
I’m repeating myself here, but I’m now almost convinced that it would be a cleaner approach to add the color space identifier to existing color pseudo functions, e.g.: |
@Crissov What are the use cases that justify this added complexity? Do we really need more usage of flawed color models like HSL? Also, this is an orthogonal issue to what we're discussing here. If you want to discuss that proposal, please open a new issue. |
@Crissov wrote:
Proposals of the form "let us take a spec which is being implemented, and change all the things including stuff that has been stable for years if not decades" have a significant cost. This particular one also, as @LeaVerou points out, encourages use of HSL and HWB. |
I think it's perfectly reasonable to only accept the
Currently the unifying aspect of color spaces that you can express with |
Added as a separate issue how I think Update: Recalibrated my understanding of percentages in |
A first proposal that maintains the current
On the invention front, Photoshop clamps a/b in CIELAB to I'll add one more reason for allowing all color formats to be expressed as |
We were actually discussing this last night with @svgeesus. That even without OKLab and friends, currently our use of percentages is inconsistent because in Lab
The advantage of 5 is that it makes color formats portable. For example, people can experiment in OKLCH without knowing intimate details about OKLCH because there is already a range they can tap into. It also means they can use It would also make it easier to develop meta tools, like color pickers if there's a reference range for every coordinate, so that's useful in its own right. |
Which is really dumb because
On the other hand I have also seen systems clamp a and b to ±100 which is even worse. |
For all |
I am very enthusiastic about the web platform defining the reference ranges and agree about the advantages of percentages in all components of the |
As a general principle, we need to balance current utility with future utility, which won't happen if you can only go up to 50-60% on most coordinates. My thinking was that |
Just to get a rough idea, I've computed ranges for some unbounded components against the
|
Thanks @danburzo, that's wonderful! So, if we were to use
|
Happy to see percentages being explored as being context-aware instead of forcing a color to map to 0 - 100 🙂. I think this makes way more sense. |
sqrt ( 0.4^2 + 0.4^2 ) = 0.566 so the reference range for OKLCH Chroma seems odd |
I think that is part of the problem with trying to treat both |
I've made an Observable notebook to eyeball the ranges for CIE/OK color spaces: https://observablehq.com/@danburzo/lab-reference-ranges (Visually works best on Chrome 94+, which has support for the |
My conclusion after fiddling with the aforementioned prototype is that a range that accommodates an entire RGB gamut is at odds with a range in which picking colors at random has a good chance of landing in gamut, or perceptually close to in-gamut. This is due to how RGB gamuts waltz around on the a/b spectrum as you increase L from 0% to 100%. Here they are for cielab-125.mp4The ideal balance doesn't seem readily apparent. If gamut mapping is good enough, so that even if you write an out-of-gamut color it still looks fairly like you'd expect, then I think that tilts the balance in favor of gamut accommodation, and to that end bounding box of display-p3 gamut expanded to round-feeling values sounds reasonable. |
Getting back to this and playing with the observable some more, the values proposed by Lea look workable to me. Agenda+ to get implementer input and agreement to add these reference percentage ranges to the spec. |
Ah, good, I updated Typed OM to reflect all the recent changes in Color 4, and ran across the xyz "numbers only, no percents" part of the grammar and was sad. I punted on it temporarily, so if this goes thru it'll mean I don't have to add extra complexity. |
Okay so |
For the call, to see the full proposal in one place, the percentages would be explicitly defined so that 0% to 100% maps as follows::
No-one mentioned hue as a percentage so it remains an angle, in degrees by default if no unit is given. This gives useful ranges for percentages on all colors, roughly covering the It also means people can paste in
|
If I'm going to be picky, it feels odd to set the oklab values to +/- 0.4. Making them +/- 0.5 (so the total range is 1) feels a bit more natural and less likely to trip people up, particularly as oklab/oklch are new and unfamiliar to most. (note this would also match the current text from css-color-4: "theoretically unbounded (but in practice do not exceed ±0.5).") For Lab/LCH, those seem fine - it's arbitrary of course. A big +1 to making XYZ primaries percentages, as I had the same reaction as Tab when adding these. |
The CSS Working Group just discussed
The full IRC log of that discussion<emeyer> Topic: [css-color] Support all existing (non-legacy?) formats in color()?<emeyer> Github: https://github.com//issues/6741 <Rossen_> q: <Rossen_> q <emeyer> lea: Looking for consensus for our plan on percentages. Right now they’re aliased to 0-1 ranges. <emeyer> …We were thinking o using them for a reference range based on p3 so people can use absolute coordinates if they want, or use percentages if they want something close enough. <lea> https://github.com//issues/6741#issuecomment-1028141623 <emeyer> s/ o / of / <emeyer> chris: Mostly I wanted more feedback just to be sure this is what we want to do. <emeyer> lea: What’s unclear is whether this about the color() function or is it about other things? <emeyer> chris: It’s about the other things. <emeyer> Lea: we really need a new issues. <emeyer> Rossen: We can definitely get a different issue. Chris, you framed this as a question toward implementors, so let’s hear from them. <emeyer> Mike Bremford: Changing it isn’t a big deal either way. <emeyer> TabAtkins: +1 from me as well. I like this from the perspective of “all color models accept the same input space”. <lea> Note that this means that color(rec2020 50% 100% 50%) will NOT be equal to color(rec2020 .5 1 .5) <emeyer> Rossen: Any objections? <lea> (+1 from me too, in case it's not clear) <emeyer> …As next steps, we’ll break this out into its own issue, build consensus, and get it into a spec. <emeyer> RESOLVED: Will add this to the color-4 module, after forking to a new issue |
Redirecting discussion back to original subject:
A little progress since the issue was first raised:
The other ones are opponent color spaces (neutral central axis with perceptual Lightness); |
In CMYK (0,0,0,0) is white. |
/facepalm |
CMYK is also in CSS Color 5. So the arguments given all apply, to CSS Color 4. Incidentally ITC H.273 describes XYZ among its list of RGB color spaces, which is true as the primary chromaticities are: red: x=1, y=0 |
Closing this old issue since the spec has changed a fair bit since the issue was first raised. |
Hi @svgeesus, just to make the conclusion explicit: unbound color spaces (that is |
Correct. |
Uh oh!
There was an error while loading. Please reload this page.
Yes, I know there are unresolved issues wrt to representing polar coordinates in
color()
and we'd need to solve these first. Maybe by changing its grammar to be[<number-percentage> | <angle> | none]+
instead of[<number-percentage> | none]+
.Why should we be able to represent all existing color formats through
color()
?color()
is murky. The spec describescolor()
as "Profiled, Device-dependent Colors", but also includes the XYZ spaces there.color()
so that e.g. they can use OKLCH if that's supported or LCH if not.color()
or as separate functions, imagine how difficult authors will find it to remember the distinction.Reasons against doing this:
color(lab)
. If we adopt this proposal, we'd need to actually pick this time.The text was updated successfully, but these errors were encountered: