Previous appendix To contents Next appendix

Appendix G, Image.Layer modes

The variables in the expression:
L
The active layer
S
The source layer (the sum of the layers below)
D
The destintion layer (the result)
Xrgb
Layer red (Xr), green (Xg) or blue channel (Xb)
Xhsv
Layer hue (Xh), saturation (Xs) or value channel (Xv) (virtual channels)
aX
Layer alpha, channel in layer alpha
All channels are calculated separately, if nothing else is specified.
top layer
bottom layer
 
normalD=(L*aL+S*(1-aL)*aS) / (aL+(1-aL)*aS), aD=(aL+(1-aL)*aS)
 
addD=L+S, apply alpha as "normal" mode
subtractD=L-S, apply alpha as "normal" mode
multiplyD=L*S, apply alpha as "normal" mode
divideD=L/S, apply alpha as "normal" mode
moduloD=L%S, apply alpha as "normal" mode
invsubtractD=S-L, apply alpha as "normal" mode
invdivideD=S/L, apply alpha as "normal" mode
invmoduloD=S%L, apply alpha as "normal" mode
differenceD=abs(L-S), apply alpha as "normal" mode
maxD=max(L,S), apply alpha as "normal" mode
minD=min(L,S), apply alpha as "normal" mode
bitwise_andD=L&S, apply alpha as "normal" mode
bitwise_orD=L|S, apply alpha as "normal" mode
bitwise_xorD=L^S, apply alpha as "normal" mode
 
replaceD=(L*aL+S*(1-aL)*aS) / (aL+(1-aL)*aS), aD=aS
redDr=(Lr*aLr+Sr*(1-aLr)*aSr) / (aLr+(1-aLr)*aSr), Dgb=Sgb, aD=aS
greenDg=(Lg*aLg+Sg*(1-aLg)*aSg) / (aLg+(1-aLg)*aSg), Drb=Srb, aD=aS
blueDb=(Lb*aLb+Sb*(1-aLb)*aSb) / (aLb+(1-aLb)*aSb), Drg=Srg, aD=aS
 
replace_hsvDhsv=(Lhsv*aLrgb+Shsv*(1-aLrgb)*aSrgb) / (aLrgb+(1-aLrgb)*aSrgb), aD=aS
hueDh=(Lh*aLr+Sh*(1-aLr)*aSr) / (aLr+(1-aLr)*aSr), Dsv=Lsv, aD=aS
saturationDs=(Ls*aLg+Ss*(1-aLg)*aSg) / (aLg+(1-aLg)*aSg), Dhv=Lhv, aD=aS
valueDv=(Lv*aLb+Sv*(1-aLb)*aSb) / (aLb+(1-aLb)*aSb), Dhs=Lhs, aD=aS
colorDhs=(Lhs*aLrg+Shs*(1-aLrg)*aSrg) / (aLrg+(1-aLrg)*aSrg), Dv=Lv, aD=aS
 
darkenDv=min(Lv,Sv), Dhs=Lhs, aD=aS
lightenDv=max(Lv,Sv), Dhs=Lhs, aD=aS
saturateDs=max(Ls,Ss), Dhv=Lhv, aD=aS
desaturateDs=min(Ls,Ss), Dhv=Lhv, aD=aS
 
dissolvei=random 0 or 1, D=i?L:S, aD=i+aS
behindD=(S*aS+L*(1-aS)*aL) / (aS+(1-aS)*aL), aD=(aS+(1-aS)*aL); simply swap S and L
eraseD=S, aD=aS*(1-aL)
 
screen1-(1-S)*(1-L), apply alpha as "normal"
overlay(1-(1-a)*(1-b)-a*b)*a+a*b, apply alpha as "normal"
burn_alphaaD=aL+aS, D=L+S; experimental, may change or be removed
 
equaleach channel D=max if L==S, 0 otherwise, apply with alpha
not_equaleach channel D=max if L!=S, 0 otherwise, apply with alpha
lesseach channel D=max if L<S, 0 otherwise, apply with alpha
moreeach channel D=max if L>S, 0 otherwise, apply with alpha
less_or_equaleach channel D=max if L<=S, 0 otherwise, apply with alpha
more_or_equaleach channel D=max if L>=S, 0 otherwise, apply with alpha
 
logic_equallogic: D=white and opaque if L==S, black and transparent otherwise
logic_not_equallogic: D=white and opaque if any L!=S, black and transparent otherwise
logic_strict_lesslogic: D=white and opaque if all L<S, black and transparent otherwise
logic_strict_morelogic: D=white and opaque if all L>S, black and transparent otherwise
logic_strict_less_equallogic: D=white and opaque if all L<=L, black and transparent otherwise
logic_strict_more_equallogic: D=white and opaque if all L>=L, black and transparent otherwise

Previous appendix To contents Next appendix