I want to produce an opaque solid color with 2 opacity values of that color.
eg: 0.5 opacity black color rectangle when placed above same 0.5 opacity black color doesn't give me same result as an opaque (opacity 1) black color.
I have tried this with different range of opacity values and found something like 0.5 & 0.8 produce 0.9 opacity black color, 0.4 & 0.82 and so on.
These are not accurate values. What is the exact formula for calculating exactly opposite opacity values?
If two elements with opacity 1-a
and 1-b
are stacked on top of each other, their combined opacity will be 1-a*b
, so there's no such thing as "opposite opacity values".
If you want two elements combined to be fully opaque, then one of them has to be fully opaque itself.
This mimics the real world as well: when you stack two dark foils that each absorbs 50% of light passing through, their combined opacity is 75%, not 100%. Three foils - 87.5% and so on.
来源:https://stackoverflow.com/questions/13190432/2-opposite-opacity-values-dont-produce-opaque-color