Both pstricks
and PGF
/TikZ
can produce all the required blend modes. However it seems that pstricks.tex
in TeXLive 2013 (a) only defines some of the blend modes supported by ghostscript (at least from version 9.14), and (b) has a bug where Ligten
should read Lighten
.
It is (as far as I can tell) quite simple to amend this, although I should caution I am no pstricks
expert. The following shows all the blend modes for both packages and should be compiled with xelatex
. It may not work with earlier versions of ghostscript.
\documentclass[border=5]{standalone}
\usepackage{pstricks}
\usepackage{tikz}
\makeatletter
\pst@def{setBlendmode}<
\ifcase\psk@blendmode
/Normal \or
/Compatible \or
/Screen \or
/Multiply \or
/HardLight \or
/Darken \or
/Lighten \or
/Difference \or
/ColorDodge \or
/ColorBurn \or
/SoftLight \or
/Hue \or
/Saturation \or
/Luminosity \or
/Overlay \or
/Exclusion \or
/Color
\else
/Normal
\fi
.setblendmode \psk@shapealpha .setshapealpha >
\makeatother
\pgfkeys{%
ps blend mode/.style={/ps blend mode/.cd, #1/.try},
ps blend mode/.cd,
normal/.code=\psset{blendmode=0},
compatible/.code=\psset{blendmode=1},
screen/.code=\psset{blendmode=2},
multiply/.code=\psset{blendmode=3},
hard light/.code=\psset{blendmode=4},
darken/.code=\psset{blendmode=5},
lighten/.code=\psset{blendmode=6},
difference/.code=\psset{blendmode=7},
color dodge/.code=\psset{blendmode=8},
color burn/.code=\psset{blendmode=9},
soft light/.code=\psset{blendmode=10},
hue/.code=\psset{blendmode=11},
saturation/.code=\psset{blendmode=12},
luminosity/.code=\psset{blendmode=13},
overlay/.code=\psset{blendmode=14},
exclusion/.code=\psset{blendmode=15},
color/.code=\psset{blendmode=16}
}
\def\psshowblend#1{%
\psset{unit=0.5cm,fillstyle=shape,linestyle=none,shapealpha=0.75}%
\pgfkeys{ps blend mode=#1}
\SpecialCoor
\begin{pspicture}[shift=-1.5](-1.5,-1.5)(4.5,1.5)
\pscircle[fillcolor=red](.5;90){1}
\pscircle[fillcolor=green](.5;210){1}
\pscircle[fillcolor=blue](.5;330){1}
\rput(3,0){
\pscircle[fillcolor=yellow](.5;90){1}
\pscircle[fillcolor=cyan](.5;210){1}
\pscircle[fillcolor=magenta](.5;330){1}
}
\end{pspicture}
}
\def\tikzshowblend#1{%
\begin{tikzpicture}[x=0.5cm,y=0.5cm, blend mode=#1, opacity=0.75, baseline={(0,0)}]
\useasboundingbox (-1.5,-1.5) rectangle (4.5,1.5);
\fill [red] ( 90:.5) circle [radius=1];
\fill [green] (210:.5) circle [radius=1];
\fill [blue] (330:.5) circle [radius=1];
\tikzset{shift=(0:3)}
\fill [yellow] ( 90:.5) circle [radius=1];
\fill [cyan] (210:.5) circle [radius=1];
\fill [magenta] (330:.5) circle [radius=1];
\end{tikzpicture}
}
\catcode`\|=13
\def|{\verb|}
\begin{document}
\begin{minipage}{5in}
\hskip1in\hbox to 2in{\hfil|pstricks|\hfil}\hbox to 2in{\hfil|tikz|\hfil}\par
\vskip0.5cm%
\foreach \mode in {normal, multiply, screen, overlay, darken, lighten, color dodge, color burn, hard light, soft light, difference, exclusion, hue, saturation, color, luminosity}{%
\leavevmode\hbox to 1in{\tt\mode\hfil}%
\hbox to 2in{\hfil\psshowblend{\mode}\hfil}%
\hbox to 2in{\hfil\tikzshowblend{\mode}\hfil}\hfil\par%
}
\end{minipage}
\end{document}

Following the OP's comment above, here is some examples with a picture in the background using only TikZ
this time (pstricks
can do it as well, I am just more familiar with TikZ
).
The picture is not very exciting but the code overlays red, green and blue circles at varying levels of transparency to illustrate the different blend modes:
\documentclass[tikz,border=5]{standalone}
\begin{document}
\begin{tikzpicture}
\foreach \mode [count=\n from 0, evaluate={\x=mod(\n,2)*5; \y=-floor(\n/2)*4;}] in {normal, multiply, screen, overlay, darken, lighten, color dodge, color burn, hard light, soft light, difference, exclusion, hue, saturation, color, luminosity}{%
\begin{scope}[shift={(\x,\y)},local bounding box=mode]
\foreach \c [count=\i] in {red, green, blue}{
\foreach \j [evaluate={\o=(\j+1)/4;}] in {0,...,3}{
\begin{scope}[shift=(90:2-\i), shift=(0:\j), scale=0.25]
\begin{scope}[opacity=0.75]
\fill [red] ( 90:.5) circle [radius=1];
\fill [green] (210:.5) circle [radius=1];
\fill [blue] (330:.5) circle [radius=1];
\end{scope}
\begin{scope}[blend mode=\mode, opacity=\o]
\fill [fill=\c] circle [radius=1.875];
\end{scope}
\end{scope}
}
}
\end{scope}
\node [above] at (mode.north) {\tt\mode};
}
\end{tikzpicture}
\end{document}
