# [pstricks] mixing colours of overlapping objects while disregarding paper background colour

Alexander Grahn A.Grahn at fzd.de
Wed Jun 10 14:53:57 CEST 2009

Hi,

I wish it were possible to mix the colour of overlapping objects but,
at the same time, to prevent the background colour from being mixed in.

Consider the example below where I have a red (rgb=1 0 0) circle and a
blue (rgb=0 0 1) ellipse, overlapping each other. It would be extremely
nice to have the overlapping region to be filled with colour rgb=1 0 1
and the non-overlapping regions to be filled with fully saturated red
and blue colours.

Unfortunately, neither black nor white backgrounds give the desired
result.

Is there a way to achieve this in the final ps2pdf generated PDF?

Regards,
Alexander

\documentclass{article}
\usepackage{pstricks}

\def\ColoredOverlappedSurfaces#1#2#3#4{%
\psset{fillstyle=solid,opacity=0.5}%
\psset{fillcolor=#2}#1
\psset{fillcolor=#4}#3}

\pagestyle{empty}

\begin{document}

\psset{unit=2}
\psframebox*[fillcolor=black,fillstyle=solid]{%
\begin{pspicture}(-2,-2)(2,2)
\rput(0,0){%
\ColoredOverlappedSurfaces{\pscircle{1}}{red}{\psellipse(0.3,-0.7)(1.5,1)}{blue}}
\end{pspicture}}

\begin{pspicture}(-2,-2)(2,2)
\rput(0,0){%
\ColoredOverlappedSurfaces{\pscircle{1}}{red}{\psellipse(0.3,-0.7)(1.5,1)}{blue}}
\end{pspicture}
\end{document}