Mix colors () () ratio () : () block

Do you understand what the A in RGBA means?

yes, alpha/transparency.

OK, so what don't you understand? Do you see the relationship between transparency and blending?

no, I don't.

Ah. The way you blend two colors in computer display isn't by pouring them both out and stirring, as in paint. It's by putting down one opaque color and laying a colored partly-transparent piece of plastic, like the lenses in sunglasses, in front of it. That's a metaphor, but it's a metaphor for having an opaque color (alpha = 255, or in ratio terms alpha = 1) and then putting another color in front of it, whose alpha value determines how much of each color you see.

So I guess I was wrong about 1-ratio; if you do that, some of the background will also be part of the blend. I was trying to treat the two colors symmetrically. But that wikipedia formula assumes that it knows which is the foreground (partly transparent) color.

I looked at

and now I understand, though I still want it to be like mixing like paint. after I edited pumpkinhead's script, I came up with this:

and
and it seems to work for me.
my question is why I need to switch color 1 and color 2.

Presumably because you're confused about what p means in your formula. That's the only asymmetry.

But I don't understand your formula at all. You are multiplying all of R, G, B, and A by A, which is a fraction. That doesn't only make the color more transparent; it makes it darker, too. I'm guessing you aren't noticing that because the colors are both partly transparent against a white background, and maybe the partly-seen white behind the mixed colors sort of undoes the darkening.

But, basically you're fighting understanding how colors really work, so it's not surprising if your program doesn't work the way you expect!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.