Define RGBA color obtained by combining two colors

I have two colors defined as RGBA (in my specific examples, one of them is [white with alpha 0.85] and [57, 40, 28 with alpha 0.25]. The second color is drawn above the first (ie white with alpha is the background, and the second color is used for drawing). How can I find out what the color of the RGBA combination will be? I need to do one-time - so any tools are fine (for example, I’m “I'm happy to do something in Photoshop and see what happens”) .

I have several sets for combining, but not too many. Any pointers? Thanks.

+7
source share
1 answer

When using the Painter algorithm, most color compositions are performed using the Porter-Duff "Over" mode:

Resulting Alpha:

αr = αa + αb (1 - αa) 

Resulting color components:

 Cr = (Ca αa + Cb αb (1 - αa)) / αr 

So for your example:

 alpha = 0.25 + 0.85 * (1 - 0.25) = 0.8875 red = (57 * 0.25 + 255 * 0.85 * (1 - 0.25)) / 0.8875 = 199.2 green = (40 * 0.25 + 255 * 0.85 * (1 - 0.25)) / 0.8875 = 194.4 blue = (28 * 0.25 + 255 * 0.85 * (1 - 0.25)) / 0.8875 = 191.1 

See the wikipedia article on alpha linking.

+17
source

All Articles