[pstricks] what's wrong with these codes (from pstricks manual (p223)
Herbert Voss
Herbert.Voss at FU-Berlin.DE
Wed Feb 1 16:43:29 CET 2017
Am 01.02.2017 um 02:40 schrieb Dong Li:
> Hello,
>
> what's wrong with these codes (from pstricks manual (p223). It doesn't
> work. Who can help me modify these codes. Thanks!
what means "it doesn't work"??
Herbert
>
>
>
> \documentclass{article}
> \usepackage[dvipsnames,x11names,svgnames]{pstricks}
>
> \makeatletter
> \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{{%
> \psset{linestyle=none}%
> \use at par% Assignment of local parameters
> \bgroup
>
> \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
> \egroup
> \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}%
> \fi
> % 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}%
> \psset{fillstyle=solid,fillcolor=MixedColor}%
> \csname PstColorSynthesis at Surface#1\endcsname
> \endpsclip}
> \def\PstColorSynthesis at MixedColor#1{%
> \edef\@tempa{#1}%
> \ifx\@tempa\@empty
> \else
> \pst at expandafter\PstColorSynthesis at MixedColor@i{%
> \csname\string\color@#1\endcsname}\@nil
> \fi}
>
> \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
> \fi}
>
> \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)
> \ifdim#1\p@>\@ne\p@
> \def#1{1}%
> \fi}
>
> % We redefine Cyan, Magenta and Yellow in the ?rgb? model
> \definecolor{Cyan}{rgb}{0,1,1}%
> \definecolor{Magenta}{rgb}{1,0,1}%
> \definecolor{Yellow}{rgb}{1,1,0}%
> \makeatother
>
> \begin{document}
>
> \begin{pspicture}
> \PstColorSynthesis[SurfaceA={\pscircle{2}},
> SurfaceB={\pscircle(2,0){2}},SurfaceC={\pscircle(1,2){2}},
> ColorA=Cyan,ColorB=Magenta,ColorC=Yellow]
>
> \PstColorSynthesis[SurfaceA={\psccurve(-3,1)(0,2.5)(2,1.5)(4,3)(4,-1)
> (3,0)(1,-2.5)(-1,-1)(-3,-3)},
> SurfaceB={\psellipticarc(0,-1)(3,1.5){41}{-92}},
> SurfaceC={\pstriangle(1,-2)(5,5)},
> ColorA=SlateBlue,ColorB=Orange,ColorC=Pink]
> \end{pspicture}
> \end{document}
>
>
>
>
>
>
> _______________________________________________
> PSTricks mailing list
> PSTricks at tug.org
> http://tug.org/mailman/listinfo/pstricks
> archive: http://www.tug.org/pipermail/pstricks/
>
More information about the PSTricks
mailing list