I have been trying to get a correct result in a language agnostic way. currently using excel to pin it down. I have attached an image of my current status. In this example I am starting with the background colour of #7D01FF
and and over source colour of #FFFF01
at 50% opacity the resulting colour is #7D0180
with formula
=( (E13/255)* ( (D13/255)*( (D$16/255) + ( ((C13/255)*(C$16/255)) * (1-(D$16/255) ))) / ( (D$16/255) + ((C$16/255) * (1-(D$16/255))) )) ) *255
aka
Cb * (cs*αs) + ((ca*αa) * (1-αs))/αo
where
αo is αs+αa*(1-αs)
and
Blend(multiply) is Cb*Cs
C being the chanels R, G, B each as a seperate calculation.
I have assumed (as I am unsure what else to do) that for this caclulation the initial transparency is calculated as if on a white back ground.
instead of getting the expected purple I am getting a red with the values rgba(125,1,1,255)
or #7D0101
I am self teaching (largely and referring to things like: https://en.wikipedia.org/wiki/Alpha_compositing https://www.w3.org/TR/compositing-1/#simplealphacompositing I also looked at How to blend 2 transparency layers? and it is similar but does not yield the correct result in my situation.
I am trying to set up the basis of a Design token catalogue for a design system based (loosely) around material design and have a BFa with an on and off history with computer programming, So please be kind to me.
update
Maybe I am not getting it but this doesn't arrive at the result I am expecting. I will update further in a little bit.
Update
So the result I am getting is RGB, a (201 180 180, 75%) When the result I am expecting is RGB, a (126 0 8, 100%). I am obtaining these values from Illustrator in RGB color space.
I think there is another step I am missing. I will list the equations below and include an image that may offer some context.
a = RGB(255, 255, 1) on upper layer & the layer alpha = 50% Multiply blend
b = RGB(125, 1, 255) layer alpha 100% Normal blend
t assumed to be 50% for even blend
Alpha of R = (1-0.5)(127.5/255) + 0.5(255/255)
Color of R = [rgb] = √( (1 - t) * (c1[n])2 + t * c2[n]2)
R[rgb] = [ √( 0.5 * 65025 + 0.5 * 15625), √( 0.5 * 65025 + 0.5 * 1), √( 0.5 * 1 + 0.5 * 65025)
alpha = (1-0.5)(127.5/255) + 0.5(255/255)
R[rgb] = [201 180 180] with alpha 75%
I don't know what I am missing, or doing wrong.
An image providing colors and context of above mentioned formulas.