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

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -