- From: Lea Verou via GitHub <sysbot+gh@w3.org>
- Date: Fri, 12 Apr 2024 23:18:09 +0000
- To: public-css-archive@w3.org
> I think it would be a stretch if `none` in `calc(h + 20)` was preserved as `calc(none + 20)` and actually had an observable effect in the interpolation. > > I am not even sure what such an effect might be. Trivial example: ```css --color-background: oklch(from canvas max(.2, l) 0 none) --color-primary-light: color-mix(in oklch, var(--color-background) 80%, var(--color-primary)); oklch(calc(l + 20) calc(c * .8); --color-primary: var(--color-blue); ``` > I don't agree the 3rd is the most useful, but I might be missing the utility :) For it to be useful it needs to have an observable effect and I can only imagine this case : > > ``` > color-mix(in hsl, hsl(from hsl(none 50% 50%) calc(h + 20) s l), hsl(50deg 50% 50%)) > ``` > > That is an interpolation between : > > * `hsl(from hsl(none 50% 50%) calc(h + 20) s l)` > * `hsl(50deg 50% 50%)` > > I think it would be a stretch if `none` in `calc(h + 20)` was preserved as `calc(none + 20)` and actually had an observable effect in the interpolation. > > I am not even sure what such an effect might be. I think that’s pretty straightforward: `none` becomes the same value as the analogous component of the other color whenever it gets interpolated. The calculation would then happen on that value, and that would become the starting value for the interpolation. It basically allows you to create dynamic colors that only fully resolve when interpolated with other colors! > I think the specification got it right and that `none` always becomes `0` any time it is used in a math expression. I think preserving it in calculations would make `none` *even more* useful and as a bonus, it would address all the weirdness around things like "is `calc(none)` `none` or `0`?". The intent behind the thing about converting it to 0 was that when converting between color spaces, there's no reasonable way to preserve it. With calculations there is. The more I think about it, the more I think we should *explicitly* clarify that color space conversion is the *only* case when `none` is converted to `0` (and even then, we can avoid it in some cases) and drop the stuff about calculations. So basically: - `none` gets converted to the analogous component of the other color during interpolation - `none` gets converted to `0` during color space conversion, with the exceptions of: - If the target color space includes an analogous component, then it remains `none` - If *all* components in the source color (except alpha) are `none`, then they remain `none`. - `none` gets preserved in all other cases. @svgeesus thoughts? -- GitHub Notification of comment by LeaVerou Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/10151#issuecomment-2052685363 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Friday, 12 April 2024 23:18:10 UTC