1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283typemode=|Normal|Multiply|Screen|Overlay(* | SoftLight | HardLight *)|ColorDodge|ColorBurn|Darken|Lighten|Difference|Exclusion(* | Luminosity | Color | Saturation | Hue *)(* look at gxblend.c of ghostscript *)letblend=function|Normal->funsrc_dst->src|Multiply->funsrcdst->lett=dst*src+0x80inlett=t+tlsr8intlsr8|Screen->funsrcdst->lett=(0xff-dst)*(0xff-src)+0x80inlett=t+tlsr8in0xff-tlsr8|Overlay->funsrcdst->lett=ifdst<0x80then2*dst*srcelse0xf301-2*(0xff-dst)*(0xff-src)inlett=t+0x80inlett=t+tlsr8intlsr8(*
| SoftLight ->
if s < 0x80 then begin
let t = (0xff - (src lsl 1)) * art_blend_sq_diff_8[dst] in
let t = t + 0x8000 in
dst - t lsr 16
end else begin
let t = ((src lsl 1) - 0xff) * art_blend_soft_light_8[dst] in
let t = t + 0x80 in
let t = t + t lsr 8 in
dst + t lsr 8
end
*)|ColorDodge->funsrcdst->ifdst=0then0elseifdst>=srcthen0xffelse(0x1fe*dst+src)/(srclsl1)|ColorBurn->funsrcdst->letdst=0xff-dstinifdst=0then0xffelseifdst>=srcthen0else0xff-(0x1fe*dst+src)/(srclsl1)|Darken->funsrcdst->ifdst<srcthendstelsesrc|Lighten->funsrcdst->ifdst>srcthendstelsesrc|Difference->funsrcdst->lett=dst-srcinift<0then-telset|Exclusion->funsrcdst->lett=(0xff-dst)*src+dst*(0xff-src)inlett=t+0x80inlett=t+tlsr8intlsr8openColorletfblendmodesrcalpha=letblender=blendblendmodeinmatchsrcalphawith|0->fun_srcdst->dst|255->funsrcdst->{r=blendersrc.rdst.r;g=blendersrc.gdst.g;b=blendersrc.bdst.b}|_->leta'=255-srcalphainfunsrcdst->{r=(blendersrc.rdst.r*srcalpha+dst.r*a')/255;g=(blendersrc.gdst.g*srcalpha+dst.g*a')/255;b=(blendersrc.bdst.b*srcalpha+dst.b*a')/255}