# How to calculate the RGB color values with a given alpha value for mixing with another color to achieve a target color?

Basically what I am trying to achieve is illustrated in this Image:

I got a background color (R:19 G:25 B:37 or #141A25) upon which I want to layer another color at 80% alpha to get a target color (R:52 G:96 B:29 or #415C1E). I am looking for the specific RGB values of that 2nd color I am layering over the background and how to calculate them.

While I can get there through approximation and messing about (in the example it is only 98% there), I'd like to know how to get there through calculation rather than wasting 5+ minutes shifting color values.

Thanks in advance for any help! :)

• Your wording seems a bit weird but your image seems to indicate that you are in fact asking the same question as in this question with answer Aug 5, 2018 at 21:43
• @Rafael the 5+ minutes were meant per instance. I need to apply this more than once which is why i asked for how to calculate it and the given example is meant to me exactly that - an example. I am not a designer by education so I never learned about color theory. What I came up with googling didn't give me the results I was looking for - maybe I was googling for the wrong terms but I definitely put in effort into researching a solution before coming here. Aug 5, 2018 at 22:00
• @joojaa Thanks for the link - I didn't find that when I was googling. I also edited my question for clarity - I am not looking for hex values. Also thanking people in advance for their effort to answer was just meant as being polite - I don't know what your experience is on StackExchange... I think politeness always has a place - especially when asking question. :) Aug 5, 2018 at 22:06
• [Reply to deleted discussion removed.] Anyway hexavalues are the same values as to 0-255 values. Personally i prefer rgb colors in decimal notation 0.0 to 1.0 because they are easier to compute with Aug 5, 2018 at 22:35
• If all you need is the opaque color value you can simply use the color picker to get the exact color. Aug 6, 2018 at 8:29

Calculate separately for r, g and b (decimal 0....255) the following formula

X=(T-(1-A)*B)/A

X=the new rgb number, T=target rgb number, B=background rgb number, A=alpha (0...1, 0=fully transparent)

If you get negative number or greater than 255, the goal was impossible.