For example, I know the color is #a0c5e8 (160,197,232) when over white, and it's #496e91 (73,110,145) when over black.
Is there a way to calculate the "real" color (at 100% opacity)?
For example, I know the color is #a0c5e8 (160,197,232) when over white, and it's #496e91 (73,110,145) when over black.
Is there a way to calculate the "real" color (at 100% opacity)?
Yes you can, by solving a system of linear equations. Let's look at the red channel as an example:
Variables:
c - color (unknown)
f - opacity (unknown)
Equations:
c * f + (1 − f) * 255 = 160. (blending with white)
c * f + (1 − f) * 0 = 73. (blending with black)
Rearrange to get:
c * f − 255 f = −95.
c * f = 73.
255 f = 168.
Therefore:
f = 168/255 ≈ 65.9%.
c = 6205/56 ≈ 110.8.
Computing the other channels, your final color is (111,167,220) and opacity is 66%.