I'm looking for a formula which would take any opaque color (shown on the left in each scenario above) and output a semi-transparent color which is essentially the equivalent given a white background. It seems to be straightforward for any grayscale color (eg. the first gray: 1-(32/255) -> 0.87), but not sure what to do with other colors.
Note how they appear to be the exact same colors anywhere there is a white background even though they are clearly different colors.
I found a wikipedia page on alpha compositing but I don't know how to use it to do what I want. I saw this question but it's not exactly the same. Finally, I think this "Color to alpha" gimp filter is essentially what I want to do, always using white as the color - but there is no documentation on how it's being done. Any help is appreciated.
Essentially looking for a function like this...
function whiteToAlpha(r, g, b) {
// ...
return [newR, newG, newB, newAlpha]
}
