Re: [csswg-drafts] [css-color-6] How to support color math involving more than one color? (#11533)

The CSS Working Group just discussed `[css-color-6] How to support color math involving more than one color?`, and agreed to the following:

* `RESOLVED: Yes to this issue, let's get it in a spec and start work on it`

<details><summary>The full IRC log of that discussion</summary>
&lt;kbabbitt> lea: a while back we resolved to adopt relative color syntax<br>
&lt;kbabbitt> ...<br>
&lt;kbabbitt> ... it's now in every browser, allows for math based on components of colors<br>
&lt;kbabbitt> ... use cases that involve more than one color keep cropping up<br>
&lt;hober> q+<br>
&lt;kbabbitt> ... e.g. mixing certain components from one color and other compionents from another<br>
&lt;kbabbitt> ... had an internal use case using components from one color and alpha from another<br>
&lt;kbabbitt> ... polyfilling other features can require components from multiple colors<br>
&lt;kbabbitt> ... e.g. two color operations like blending modes<br>
&lt;kbabbitt> ... it seems clear that there are use cases for this to be possible in some way<br>
&lt;kbabbitt> ... question is what's the best syntax<br>
&lt;kbabbitt> ... possibly extending color-mix but that could be a more complex syntax<br>
&lt;kbabbitt> ... not extensible to more than 2 colors<br>
&lt;kbabbitt> ... in another issue we resolved to add color-extract function<br>
&lt;kbabbitt> ... security and privacy implications so we might not see that anytime soon<br>
&lt;kbabbitt> ... it seems to me an extension on existing RCS is probably best way<br>
&lt;kbabbitt> ... but still how do we reference components of additional color?<br>
&lt;kbabbitt> ... could kick the ball down to authors and ask them<br>
&lt;kbabbitt> ... would prefer not to<br>
&lt;kbabbitt> ... if there's a user need we could do that later<br>
&lt;kbabbitt> ...ideally there should be default names like there are for first color<br>
&lt;kbabbitt> ... some might be comfortable with functional syntax eg. c(2)<br>
&lt;TabAtkins> q+<br>
&lt;kbabbitt> ... fantasai and I think there re too many parens already<br>
&lt;weinig> q+<br>
&lt;ChrisL> prefer c2 to c(2) or c-2<br>
&lt;kbabbitt> ... auto generating idents like c2 seems nicest way<br>
&lt;hober> q-<br>
&lt;kbabbitt> .... fine for initial vetsion to be limited in # of colors it supports<br>
&lt;emilio> q+<br>
&lt;kbabbitt> ... don't thinkm I've seen a quse case requiring more than 3<br>
&lt;kbabbitt> ... if impls want a pre defined max that's fine<br>
&lt;kbabbitt> ... other details like what if you're ref'ing an ident and you have fewer colors than that, proposals about that<br>
&lt;kbabbitt> ... can iron these out later if there's consensus on general direction<br>
&lt;astearns> ack TabAtkins<br>
&lt;kbabbitt> TabAtkins: agree with this and generally think lea's ideal case is right way to do it. +1<br>
&lt;astearns> ack weinig<br>
&lt;kbabbitt> weinig: one thing I couldn't quite understand: if you want to use channels from 2 different color spaces, would RCS support that?<br>
&lt;lea> qq+<br>
&lt;kbabbitt> ... usually RCS extracts channels in single color space<br>
&lt;kbabbitt> ... would we need to augment to define extraction?<br>
&lt;kizu> q+<br>
&lt;kbabbitt> lea: yes you can nest RCS, each time you convert to color space<br>
&lt;kbabbitt> weinig: so if you want lightness to multiply every rgb channel, extract lightness and thne put it in every channel?<br>
&lt;kbabbitt> lea: each op is done in one color space<br>
&lt;kbabbitt> ... base color can be a relative color<br>
&lt;kbabbitt> weinig: say you have a color you want its lightess from<br>
&lt;kbabbitt> ... and want to multiply every channel of an rgb color by that value<br>
&lt;kbabbitt> .... to brighten its intensity<br>
&lt;kbabbitt> lea: why not operate on lightness itself?<br>
&lt;kbabbitt> weinig: that's fair<br>
&lt;kbabbitt> lea: we can revisit color-extract later which would allow that<br>
&lt;kbabbitt> ... not sure there's enough cases but could revisit<br>
&lt;kbabbitt> weinig: your argument is strong<br>
&lt;ChrisL> In general, doing math on gamma-encoded rgb channel values is almost never useful<br>
&lt;kbabbitt> ... also: are there other areas of CSS where extracting parts of it and using those would be useful?<br>
&lt;kbabbitt> ... so that instead of color-extract we have a more generic form<br>
&lt;kbabbitt> ... to avoid color-mix to mix thing<br>
&lt;kbabbitt> ... if we were to go the extract route are there other potential use cases?<br>
&lt;kbabbitt> lea: good question, can't think of any offhand<br>
&lt;kbabbitt> weinig: don't see any downside to adding support for multiple colors<br>
&lt;kbabbitt> ... could do other things if we want<br>
&lt;astearns> ack lea<br>
&lt;Zakim> lea, you wanted to react to weinig<br>
&lt;astearns> ack emilio<br>
&lt;kbabbitt> emilio: my question was similar to weinig's<br>
&lt;kbabbitt> ...what color space is used if you have multiple<br>
&lt;kbabbitt> ...would you get components of each color in its own color space, and ... target?<br>
&lt;kbabbitt> lea: this is already defined for RCS<br>
&lt;kbabbitt> ... color converted to color space you're working in<br>
&lt;kbabbitt> emilio: color space doesn't depend on input, depends on function being used<br>
&lt;kbabbitt> lea: precisely<br>
&lt;kbabbitt> ... that's how RCS works already<br>
&lt;astearns> ack kizu<br>
&lt;kbabbitt> kizu: we need something like this<br>
&lt;kbabbitt> ...while we still want to have this in situ way of doing things<br>
&lt;kbabbitt> ... might also want color-extract<br>
&lt;kbabbitt> ... cases where it's difficult to do this in one function<br>
&lt;kbabbitt> lea: you can use CSS variables<br>
&lt;kbabbitt> kizu: can you assing custom prop with color component and then reuse?<br>
&lt;kbabbitt> lea: yes, doesn't resolve until used but could use custom prop for calculations<br>
&lt;kbabbitt> kizu: if you are not registering them you could do this<br>
&lt;kbabbitt> ... if we are a fan of color-extract for security reasons<br>
&lt;kbabbitt> ...one solution might be to do it only in custom functions that return a color<br>
&lt;lea> e.g. `--lighter: calc(l * 1.2); color: oklch(from var(--color) var(--lighter) c h);` works fine<br>
&lt;kbabbitt> s/are/aren't/<br>
&lt;kbabbitt> [crosstalk]<br>
&lt;weinig> q+<br>
&lt;astearns> ack weinig<br>
&lt;kbabbitt> weinig: what are the security/privacy concerns with extract color?<br>
&lt;kbabbitt> lea: right now you could paint certaing colors on a canvas and read them but...<br>
&lt;kbabbitt> weinig: could use gCS to read serialization<br>
&lt;kbabbitt> lea: this adds vector to CSS itself<br>
&lt;kbabbitt> ...instead of needing JS<br>
&lt;kbabbitt> ... minor point but could imagine people raising concerns<br>
&lt;kbabbitt> ... e.g. previous meeting accent-color had concerns<br>
&lt;lea> or even `--lighter: calc(l * 1.2) calc(c * 1.05); color: oklch(from var(--color) var(--lighter) h);`<br>
&lt;kbabbitt> weinig: they have to be resolved for gCS anyway<br>
&lt;kbabbitt> ... if we allow that, you can always find out channels yourself<br>
&lt;kbabbitt> lea: fair enough<br>
&lt;kbabbitt> ... fwiw even if we decide that extract-color is useful, in many cases it would be verbose, this is simpler<br>
&lt;kbabbitt> weinig: not objecting just wanted to know what security and privacy concerns were<br>
&lt;kbabbitt> astearns: shall we resolve on adding this to spec><br>
&lt;kbabbitt> weinig: I feel we need more debate on syntax for getting components<br>
&lt;kbabbitt> ... or maybe a little more thought on if this concept of indexing into an array is something we're creating here<br>
&lt;kbabbitt> ...probably not the last time CSS will need indexing into an array of objects<br>
&lt;kbabbitt> ... coming up with a syntax we're OK with in future is useful<br>
&lt;kbabbitt> astearns: could have this proposal in spec with an issue sayting we need to think about component extraction<br>
&lt;kbabbitt> weinig: ok<br>
&lt;kbabbitt> astearns: Proposed: Yes to this issue, let's get it in a spec and start work on it<br>
&lt;ChrisL> +1<br>
&lt;kbabbitt> RESOLVED: Yes to this issue, let's get it in a spec and start work on it<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11533#issuecomment-2625624517 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 30 January 2025 21:23:14 UTC