Re: [csswg-drafts] [css-color-5] How should negative percentages behave in color-mix()? (#6047)

> How so? They are still normalized to sum to 100%. 110% and -10% sum to 100%. Nobody is proposing that the percentages shouldn't normalize.

I'm somewhat confused here. The context for "sum to lt or gt than 100%" is two %s being specified, one on each color. If the two %s are 20% and 30%, or 100% and 150%, the "just scale and add the components, because that's how interpolation/extrapolation is defined" results in a very dark or very light color.

Looking at this again, tho, I think I should be reading your comments as saying "in all cases, sum the %s, then rescale them to equal 100%". So if they were 100% and -50% (sum to 50%), we'd rescale them to, hm, I guess 200% and -100%? This doesn't seem like a great answer to land on, unfortunately - if all the %s are positive the effects of scaling seem pretty reasonable, but when one is negative the re-scaling starts having outsized effects. (It's also undefined if they sum to 0%, and summing to a negative % is either undefined or *really* wacky since it'll invert the %s.)

------

> You just said that cross-fade() performs interpolation, but color-mix() should be explained in terms of "mixing", not interpolation (whatever that means).

*You* said that cross-fade() wasn't about interpolation ("Tab, cross-fade() does compositing, not interpolation."), while color-mix() was (implying that color-mix() strictly sticking with interpolation math was okay even if cross-fade() didn't). I retorted that cross-fade() was literally defined as the way images interpolate in CSS. ^_^

It is *also* true that cross-fade() is designed to conform to the mental model of "mixing" images together, not strictly following the results of interpolation math even if there is a well-defined answer when you do so.  Percentages are limited to the range [0%, 100%], because values outside that range don't make *conceptual* sense, even if the math still works out; percentages that sum to >100% are rebalanced to 100% exactly†; and percentages that sum to <100% fill the remainder with transparent to model the idea that you're only grabbing "some" of the image and mixing it in.

†: The metaphor here is that if you're throwing in "too much" of the images, you'll just make a too-large pile of pixels. When we mix them together and scoop out the correct amount to fill 100%, you'll get a result with the same ratio as the inputs originally had.  The same metaphor covers a sum < 100%; we mix them all together and measure out 100%, but the inputs didn't fill all that so there's "empty space" left in the result.

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


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

Received on Wednesday, 10 March 2021 19:00:56 UTC