Skip to content

Instantly share code, notes, and snippets.

@XProger
Last active January 10, 2024 19:33
Show Gist options
  • Save XProger/c02b1b3de662ed651380 to your computer and use it in GitHub Desktop.
Save XProger/c02b1b3de662ed651380 to your computer and use it in GitHub Desktop.
mode out color out alpha
-------------- -------------- -----------
layer/over: ( sc+(1-sa)*dc , sa+da-sa*da )
multiply: ( sc*dc , sa+da-sa*da )
screen: ( sa*da - (da-dc)*(sa-sc) , sa+da-sa*da )
lighten: ( max(sa*dc,sc*da) , sa+da-sa*da )
darken: ( min(sa*dc,sc*da) , sa+da-sa*da )
add: ( min(dc+sc,1) , min(sa+da,1) )
subtract: ( max(dc-sc,0) , min(sa+da,1) )
difference: ( abs(sa*dc-sc*da) , sa+da-sa*da )
invert: ( sa*(da-dc) , sa+da-sa*da )
overlay: ( dc < da/2.0 ? (2.0*sc*dc) : (sa*da - 2.0*(da-dc)*(sa-sc)) , sa+da-sa*da )
hardlight: ( sc < sa/2.0 ? (2.0*sc*dc) : (sa*da - 2.0*(da-dc)*(sa-sc)) , sa+da-sa*da )
sc = source color, sa = source alpha, dc = dest color, da = dest alpha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment