Re: [csswg-drafts] [css-color-4] [css-color-5] Mixing with `transparent` seems broken in implementations (#8612)

> I guess it is too late (not Web compatible) to redefine transparent as rgba(none none none 0)?

Oh absolutely, `transparent` has been transparent black since *forever*, and it's observable from all sorts of places.

> This illustrates that a linear gradient between transparent and red in srgb does not mix in extra black at the midpoint. That transparent is rgb(0 0 0 / 0) isn't observable here.

The trick is that gradients in rectangular spaces are defined to interpolate in *premultiplied* rectangular space, which has similar "basically act like you take channels from the other color" behavior, except it also works gradually as you move away from pure transparent. (Actually it changes the 4d hypercube of the rectangular space+alpha into a hypercone with a cubic base, so all `transparent` colors occupy the same point at the cone's tip and straight paths drawn thru the space look good regardless of what the starting transparent color is. Points *near* the cone tip are compacted as well, so a *mostly* transparent red vs blue only has a very minor effect on the color as you draw a path to something opaque.) 

We don't have similar geometric tricks that can be done in polar spaces, tho, because the hue dimension isn't linear so it can't just be scaled down like that. So that's why we need this extra handling, which is also all-or-nothing.

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8612#issuecomment-1624317797 using your GitHub account


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

Received on Thursday, 6 July 2023 21:14:05 UTC