[pstricks] mixing colours of overlapping objects while disregarding paper background colour
Alexander Grahn
A.Grahn at fzd.de
Wed Jun 10 16:13:20 CEST 2009
Thanks Juergen, it's perfect!
On Wed, Jun 10, 2009 at 03:40:50PM +0200, Juergen Gilg wrote:
> \makeatletter
> % Draw two overlapped surfaces, with computation of the mixed color for
> % the intersection of the surfaces
> % #1=first surface, #2=color of first surface,
> % #3=second surface, #4=color of second surface
> \def\ColoredOverlappedSurfaces#1#2#3#4{%
> \psset{fillstyle=solid}%
> % Decode the three components of the first RGB color
> \psset{fillcolor=#2}% % Draw first surface
> #1
> % Decode the three components of the second RGB color
> % Draw second surface
> \psclip{\psset{fillcolor=#4}#3}%
> \psset{fillcolor=#2!50!#4}%
> % Redraw overlapped surface in the mixed color
> #1%
> \endpsclip%
> }
> \makeatother
Now I'd like to do the same with lines. For this purpose I modified your
example (see below). However, it does not work as expected. Any Idea?
Thanks again and in advance!
Alexander
\documentclass{article}
\usepackage{pstricks}
\makeatletter
% Draw two overlapped lines, with computation of the mixed color for
% the intersection of them.
% #1=first line, #2=color of first line,
% #3=second line, #4=color of second line
\def\ColoredOverlappedLines#1#2#3#4{%
% Decode the three components of the first RGB color
\psset{linecolor=#2}% % Draw first line
#1
% Decode the three components of the second RGB color
% Draw second line
\psclip{\psset{linecolor=#4}#3}%
\psset{linecolor=#2!50!#4}%
% Redraw overlapping line segment in the mixed color
#1%
\endpsclip%
}
\makeatother
\pagestyle{empty}
\begin{document}
\psset{unit=2}
\psset{linewidth=5pt}
\psframebox*[fillcolor=black,fillstyle=solid]{%
\begin{pspicture}(-2,-2)(2,2)
\rput(0,0){%
\ColoredOverlappedLines{\qline(-2,-2)(2,2)}{red}{\qline(-2,2)(2,-2)}{blue}}
\end{pspicture}}
\begin{pspicture}(-2,-2)(2,2)
\rput(0,0){%
\ColoredOverlappedLines{\qline(-2,-2)(2,2)}{red}{\qline(-2,2)(2,-2)}{blue}}
\end{pspicture}
\end{document}
More information about the PSTricks
mailing list