-
Notifications
You must be signed in to change notification settings - Fork 658
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
[css-color-5] Relative color syntax, @color-profile named channels, and the 'e' constant #6416
Comments
I guess I agree that I think an explanation like:
So yeah |
A function would be possible, it would just make using the constants quite a chore.
That wouldn't be a Note, it needs to be actual spec text. But it sounds like you're arguing for, uh, I guess Option 1.1: all numeric constants are fine; components with the same name are allowed, but are implicitly not usable in RCS math functions because they're shadowed by the constants. (But presumably would work on their own, not wrapped in a math function.) |
Require Example: |
Please note that there is no restriction to color components being single letter. I think it's more author-friendly to ban the constants from being valid component names, though it does introduce potential backwards compat issues, as you point out. A third idea would be to have special syntax for the constants instead of just bare idents which are likely to produce more conflicts in the future. E.g. |
Circling back to this, because the user can call the components whatever they want, I think it is fine to simply say that if they choose to call a component |
I'm fine with that. Should we disallow |
Sounds good to me, that keyword is specific to color syntaxes (rather than being reserved as part of calc() syntax). And yeah, I'm fine with that conclusion. |
Relative color syntax lets you use channel keywords inside of math functions that are used inside of color functions, like
rgb(from cornflowerblue, calc(r + .1) g b)
, to do math on those channel values.@color-profile has a 'components' descriptor, letting you give names to the channels of the color profile, specifically to make them usable in relative color syntax.
V&U defines a set of numeric constants, which are special keywords only usable in math functions, which provide certain useful numeric constants like
e
orpi
.Putting all these together gives us a problem! Theoretically, you could define
@color-profile mathy { components: e pi infinity nan;}
, but then what doescolor(from cornflowerblue, mathy, calc(e + .1))
mean? Is that the value of the "e" (first) channel whencornflowerblue
is converted to the "mathy" profile? Or is it ~2.718?There's no great solution here, I fear, but I see two reasonable options:
Simply ban the numeric constants from being valid 'components' values. I suspect we will add new numeric constants very rarely, if ever, and when we do, they'll generally be multi-letter ("e" is the only common numeric constant that's a single Latin letter), so the potential for conflict is very low. I do see this causing annoyance if a colorspace happens to normally call one of its channels "e", however; the author would have to choose a different name, and might very reasonably be confused why it's not working.
In RCS we only allow the absolutely necessary numeric constants (
infinity
,-infinity
, andNaN
, all needed for serialization purposes), and ban the others.e
andpi
are only provided for convenience, after all. Then we'd only need to restrict those three keywords from 'components', which should have no practical effect at all. I don't think the lack of those constants will be a problem here; while pi is useful for converting between rectangular and cylindrical spaces, RCS does that conversion for you already, so it seems rare to actually need to refer to pi, and in the rare cases you do need to, you can still just write3.14
. However, if you are used to usinge
orpi
in math functions and want to use them here, again there's a very reasonable chance of confusion when they suddenly don't work.The text was updated successfully, but these errors were encountered: