[pstricks] PSTricks Digest, Vol 167, Issue 11

Herbert Voss Herbert.Voss at FU-Berlin.DE
Mon Jan 30 14:52:12 CET 2017

Am 30.01.2017 um 08:23 schrieb Dong Li:
> what's wrong with these codes (from pstricks manual (p223). It doesn't
> work. Who can help me modify these codes. Thanks!

please create a new thread with a useful subject and do not
answer to a digest mail which has nothing to do with your



\define at key[psset]{}{SurfaceA}{\def\PstColorSynthesis at SurfaceA{#1}}
\define at key[psset]{}{SurfaceB}{\def\PstColorSynthesis at SurfaceB{#1}}
\define at key[psset]{}{SurfaceC}{\def\PstColorSynthesis at SurfaceC{#1}}
\define at key[psset]{}{ColorA}{\def\PstColorSynthesis at ColorA{#1}}
\define at key[psset]{}{ColorB}{\def\PstColorSynthesis at ColorB{#1}}
\define at key[psset]{}{ColorC}{\def\PstColorSynthesis at ColorC{#1}}
\def\PstColorSynthesis{\pst at object{PstColorSynthesis}}%
\def\PstColorSynthesis at i{{%
		\use at par% Assignment of local parameters
		\psset{fillstyle=solid,fillcolor=\PstColorSynthesis at ColorA}%
		\PstColorSynthesis at SurfaceA
		\psset{fillcolor=\PstColorSynthesis at ColorB}%
		\PstColorSynthesis at SurfaceB
		\psset{fillcolor=\PstColorSynthesis at ColorC}%
		\PstColorSynthesis at SurfaceC
		\PstColorSynthesis at ClippedSurfaces{A}{B}{NoSurface}%
		\PstColorSynthesis at ClippedSurfaces{A}{C}{NoSurface}%
		\PstColorSynthesis at ClippedSurfaces{B}{C}{NoSurface}%
		\PstColorSynthesis at ClippedSurfaces{A}{B}{C}}}

\def\PstColorSynthesis at ColorNoSurface{}
% We draw the first surface #1 clipped by the one
% or two others #2 and #3, computing it resulting color
\def\PstColorSynthesis at ClippedSurfaces#1#2#3{%
	% We compute the “mixed” color, component by component
	\def\PstColorSynthesis at MixedColorR{0}%
	\def\PstColorSynthesis at MixedColorG{0}%
	\def\PstColorSynthesis at MixedColorB{0}%
	% \pst at dimd will contain the maximum value of the three
	% components.
	\pst at dimd=\z@
	\PstColorSynthesis at MixedColor{%
		\csname PstColorSynthesis at Color#1\endcsname}%
	\PstColorSynthesis at MixedColor{%
		\csname PstColorSynthesis at Color#2\endcsname}%
	\PstColorSynthesis at MixedColor{%
		\csname PstColorSynthesis at Color#3\endcsname}%
	% We must test if the maximum of the new computed
	% component is greater than 1, in which case we divide all
	% the three components by this value for additive synthesis.
	\ifdim\pst at dimd>\@ne\p@
	\PstColorSynthesis at MixedColor@iii{\PstColorSynthesis at MixedColorR}%
	\PstColorSynthesis at MixedColor@iii{\PstColorSynthesis at MixedColorG}%
	\PstColorSynthesis at MixedColor@iii{\PstColorSynthesis at MixedColorB}%
	% We draw the first surface, clipped by the other ones
	\psclip{\csname PstColorSynthesis at Surface#2\endcsname%
		\csname PstColorSynthesis at Surface#3\endcsname}
	\definecolor{MixedColor}{rgb}{\PstColorSynthesis at MixedColorR,
		\PstColorSynthesis at MixedColorG,
		\PstColorSynthesis at MixedColorB}%
	\csname PstColorSynthesis at Surface#1\endcsname
\def\PstColorSynthesis at MixedColor#1{%
	\pst at expandafter\PstColorSynthesis at MixedColor@i{%

\def\PstColorSynthesis at MixedColor@i#1 #2 #3 #4\@nil{%
	% We receive the name of the color model (“rgb” is expected
	% here and the three color components.)
	% We add the values to the respective components of the new
	% color to compute.
	\PstColorSynthesis at MixedColor@ii{%
		\PstColorSynthesis at MixedColorR}{#2}%
	\PstColorSynthesis at MixedColor@ii{%
		\PstColorSynthesis at MixedColorG}{#3}%
	\PstColorSynthesis at MixedColor@ii{%
		\PstColorSynthesis at MixedColorB}{#4}}

\def\PstColorSynthesis at MixedColor@ii#1#2{%
	% As these values are real numbers, we use dimension
	% registers, then we assign the computed value in a macro,
	% converting it from a dimension to a number.
	% We also keep in \pst at dimd the maximum of the values.
	\pst at dimg=#1\p@
	\advance\pst at dimg by #2\p@
	\pst at dimtonum{\pst at dimg}{#1}%
	\ifdim\pst at dimg>\pst at dimd
	\pst at dimd=\pst at dimg

\def\PstColorSynthesis at MixedColor@iii#1{%
	\pst at divide{#1\p@}{\pst at dimd}{#1}%
	% We must take care of possible rounding problems with
	% \pst at divide (for instance, 1.8/1.8 give 1.0001)

% We redefine Cyan, Magenta and Yellow in the “rgb” model


More information about the PSTricks mailing list