opacity - rgba color mixing css -
opacity - rgba color mixing css -
trying create function takes 2 rgba values , results in third. first value of opacity: 1
eg: color: rbga((0,0,0,1);
and sec opacity (set user). goal mix 2 colors, if had color , took paint tool , went on semi-transparent color b.
here effect create.
not code, values: (0,0,0,1) & (255,255,255,0.5) = (128,128,128,1) (255,0,0,1) & (255,255,255,0.5) = (225,128,128,1) (0,255,255,1) & (255,255,255,0.5) = (128,255,128,1) (0,0,255,1) & (255,255,255,0.5) = (128,128,255,1) (81,188,187,1) & (252,0,255,0.5) = (167,94,221,1) (81,188,187,1) & (102,192,110,0.5) = (92,190,148,1) (81,188,187,1) & (255,228,0,0.5) = (168,208,93,1)
here visually: (thought not exact same illustration info above)
here values:
i using javascript create function, need figure out relationship between color 1 , color 2 in way can set in code. not plenty @ math figure 1 out. so, here am.
thanks in advance!
it's simple compositing :)
c = ca*aa*(1-ab) + cb*ab
where ca component (red, greenish or bluish in turn) of colour a, cb component of colour b, , aa , ab alpha values of , b respectively (in case, aa 1).
so (81,188,87,1) , (239,133,11,0.75), get
81*1*(1-0.75) + 239*0.75 = 199.5 188*1*(1-0.75) + 133*0.75 = 146.75 87*1*(1-0.75) + 11*0.75 = 30
resulting in (199,146,30,1)
(alpha calculated = aa*(1-ab) + ab, 1 if either alpha value 1, in case)
css opacity rgba mixing
Comments
Post a Comment