ios - Overlay blend mode formula? -


i have 2 colors: 1 dynamically set , that's white 0.5 alpha. want calculate resulting white color if drawn on top of dynamic color using overlay blend mode.

i'm aware overlay combines multiply , screen blend modes.

multiply blend mode's formula is:

result color = (top color) * (bottom color) /255 

while screen blend mode's is:

result color = 255 - [((255 - top color)*(255 - bottom color))/255] 

how calculate resulting color overlay blend mode?

is there uicolor extension class out there out of box?

there 2 part of formula:

first part: if lower layer value > 127.5, following -

value unit = (255-lower layer value)/127.5

min value = lower layer value - (255-lower layer value)

overlay = (upper layer value * value unit) + min value

second part: if lower layer value < 127.5, following -

value unit=lower layer value/127.5

overlay = upper layer value * value unit

from formual can see final result depend on upper layer value. if upper layer value higher(lighter), final result more lighter.

from here.


Comments