Class Image.Layer

Description

All channels are calculated separately, if nothing else is specified.
top layer
bottom layer
normal
D=L applied with alpha: D=(L*aL+S*(1-aL)*aS) / (aL+(1-aL)*aS), aD=(aL+(1-aL)*aS)
add
D=L+S applied with alpha, aD=aS
subtract
D=S-L applied with alpha, aD=aS
multiply
D=S*L applied with alpha, aD=aS
divide
D=S/L applied with alpha, aD=aS
negdivide
D=1.0-S/L applied with alpha, aD=aS
modulo
D=S%L applied with alpha, aD=aS
invsubtract
D=L-S applied with alpha, aD=aS
invdivide
D=L/S applied with alpha, aD=aS
invmodulo
D=L%S applied with alpha, aD=aS
imultiply
D=(1-L)*S applied with alpha, aD=aS
idivide
D=S/(1-L) applied with alpha, aD=aS
invidivide
D=L/(1-S) applied with alpha, aD=aS
difference
D=abs(L-S) applied with alpha, aD=aS
max
D=max(L,S) applied with alpha, aD=aS
min
D=min(L,S) applied with alpha, aD=aS
bitwise_and
D=L&S applied with alpha, aD=aS
bitwise_or
D=L|S applied with alpha, aD=aS
bitwise_xor
D=L^S applied with alpha, aD=aS
replace
D=(L*aL+S*(1-aL)*aS) / (aL+(1-aL)*aS), aD=aS
red
Dr=(Lr*aLr+Sr*(1-aLr)*aSr) / (aLr+(1-aLr)*aSr), Dgb=Sgb, aD=aS
green
Dg=(Lg*aLg+Sg*(1-aLg)*aSg) / (aLg+(1-aLg)*aSg), Drb=Srb, aD=aS
blue
Db=(Lb*aLb+Sb*(1-aLb)*aSb) / (aLb+(1-aLb)*aSb), Drg=Srg, aD=aS
hardlight
Like photoshop hardlight layer mode, aD=aS
replace_hsv
Dhsv=Lhsv apply with alpha, aD=aS
hue
Dh=Lh apply with alpha, Dsv=Lsv, aD=aS
saturation
Ds=Ls apply with alpha, Dhv=Lhv, aD=aS
value
Dv=Lv apply with alpha, Dhs=Lhs, aD=aS
color
Dhs=Lhs apply with alpha, Dv=Lv, aD=aS
value_mul
Dv=Lv*Sv apply with alpha, Dhs=Lhs, aD=aS
darken
Dv=min(Lv,Sv) apply with alpha, Dhs=Lhs, aD=aS
lighten
Dv=max(Lv,Sv) apply with alpha, Dhs=Lhs, aD=aS
saturate
Ds=max(Ls,Ss) apply with alpha, Dhv=Lhv, aD=aS
desaturate
Ds=min(Ls,Ss) apply with alpha, Dhv=Lhv, aD=aS
hls_replace
Dhls=Lhls apply with alpha, aD=aS
hls_hue
Dh=Lh apply with alpha, Dsv=Lsv, aD=aS
hls_saturation
Ds=Ls apply with alpha, Dhv=Lhv, aD=aS
hls_lightness
Dl=Ll apply with alpha, Dhs=Lhs, aD=aS
hls_color
Dhs=Lhs apply with alpha, Dl=Ll, aD=aS
hls_lightness_mul
Dl=Ll*Sl apply with alpha, Dhs=Lhs, aD=aS
hls_darken
Dl=min(Ll,Sl) apply with alpha, Dhs=Lhs, aD=aS
hls_lighten
Dl=max(Ll,Sl) apply with alpha, Dhs=Lhs, aD=aS
hls_saturate
Ds=max(Ls,Ss) apply with alpha, Dhl=Lhl, aD=aS
hls_desaturate
Ds=min(Ls,Ss) apply with alpha, Dhl=Lhl, aD=aS
dissolve
i=random 0 or 1, D=i?L:S, aD=i+aS
behind
D=(S*aS+L*(1-aS)*aL) / (aS+(1-aS)*aL), aD=(aS+(1-aS)*aL); simply swap S and L
erase
D=S, aD=aS*(1-aL)
screen
1-(1-S)*(1-L) applied with alpha, aD=aS
overlay
(1-(1-a)*(1-b)-a*b)*a+a*b applied with alpha, aD=aS
burn_alpha
aD=aL+aS applied with alpha, D=L+S; experimental, may change or be removed
equal
each channel D=max if L==S, 0 otherwise, apply with alpha
not_equal
each channel D=max if L!=S, 0 otherwise, apply with alpha
less
each channel D=max if L<S, 0 otherwise, apply with alpha
more
each channel D=max if L>S, 0 otherwise, apply with alpha
less_or_equal
each channel D=max if L<=S, 0 otherwise, apply with alpha
more_or_equal
each channel D=max if L>=S, 0 otherwise, apply with alpha
logic_equal
logic: D=white and opaque if L==S, black and transparent otherwise
logic_not_equal
logic: D=white and opaque if any L!=S, black and transparent otherwise
logic_strict_less
logic: D=white and opaque if all L<S, black and transparent otherwise
logic_strict_more
logic: D=white and opaque if all L>S, black and transparent otherwise
logic_strict_less_equal
logic: D=white and opaque if all L<=L, black and transparent otherwise
logic_strict_more_equal
logic: D=white and opaque if all L>=L, black and transparent otherwise


Method create

Image.Layer Image.Layer(object image, object alpha, string mode)
Image.Layer Image.Layer(mapping info)
Image.Layer Image.Layer()
Image.Layer Image.Layer(int xsize, int ysize, object color)
Image.Layer Image.Layer(object color)

Description

The Layer construct either three arguments, the image object, alpha channel and mode, or a mapping with optional elements:

"image":image,
        // default: black
 
"alpha":alpha,
        // alpha channel object
        // default: full opaque
 
"mode":string mode,
        // layer mode, see mode.
        // default: "normal"
 
"alpha_value":float(0.0-1.0),
        // layer general alpha value
        // default is 1.0; this is multiplied
        // with the alpha channel.
 
"xoffset":int,
"yoffset":int,
        // offset of this layer
 
"fill":Color,
"fill_alpha":Color,
        // fill color, ie what color is used
        // "outside" the image. default: black
        // and black (full transparency).
 
"tiled":int(0|1),
        // select tiling; if 1, the image
        // will be tiled. deafult: 0, off
The layer can also be created "empty", either giving a size and color - this will give a filled opaque square, or a color, which will set the "fill" values and fill the whole layer with an opaque color.

All values can be modified after object creation.

Note

image and alpha channel must be of the same size.