vendredi 7 septembre 2012

L’option blendmode de PSTricks pour réaliser une oeuvre d’art

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{multido,pst-node}
\newpsstyle{blendmode4}{fillstyle=shape,blendmode=4,shapealpha=1,linestyle=none}
\newpsstyle{blendmode5}{fillstyle=shape,blendmode=5,shapealpha=1,linestyle=none}
\newpsstyle{blendmode6}{fillstyle=shape,blendmode=6,shapealpha=1,linestyle=none}
\newpsstyle{blendmode7}{fillstyle=shape,blendmode=7,shapealpha=1,linestyle=none}
\newpsstyle{blendmode3}{fillstyle=shape,blendmode=3,shapealpha=1,linestyle=none}
\makeatletter
\pst@def{setBlendmode}<
    \ifcase\psk@blendmode
      /Normal \or
      /Compatible \or
      /Screen \or
      /Multiply \or
      /HardLight \or
      /Darken \or
      /Lighten \or
      /Difference
    \else
      /Normal
    \fi
    .setblendmode \psk@shapealpha .setshapealpha >
\makeatother
\makeatletter
\def\psStain{\def\pst@par{}\pst@object{psStain}}%
\def\psStain@i(#1,#2){%
  \pst@killglue%
  \begingroup%
  \use@par%
\pstVerb{rrand srand                 % initializes the random generator
         /getRandReal1 {rand 2147483647 div 4 add} def
         /getRandReal2 {rand 2147483647 div 1 add} def
         /getRandReal3 {rand 2147483647 div 360 mul} def
         /getRandRealx {rand 2147483647 div 5 mul} def
         /getRandRealy {rand 2147483647 div 5 mul} def
         /getRandRealr {rand 2147483647 div 0.25 mul} def
         /rotation getRandReal3 def}%
\edef\collectePoints{}%inspiré et adapté de D.Rodriguez dans pst-eucl
\multido{\n=22.5+45.0,\N=0.0+45.0,\iP=0+2,\iQ=1+2}{8}{%
        \pstVerb{/radius1 getRandReal1 def
                 /radius2 getRandReal2 def}%
        \pnode(!radius1 \N\space rotation add PtoC #2 add exch #1 add exch){M\iP}%
        \xdef\collectePoints{\collectePoints(M\iP)}%
        \pnode(!radius2 \n\space rotation add PtoC #2 add exch #1 add exch){M\iQ}%
        \xdef\collectePoints{\collectePoints(M\iQ)}%
        }%
\multido{\i=0+1}{5}{%
        \pstVerb{%
                 /X1 getRandRealx def
                 /Y1 getRandRealy def
                 /R1 getRandRealr def
                 /X2 getRandRealx neg def
                 /Y2 getRandRealy def
                 /R2 getRandRealr def
                 /X3 getRandRealx neg def
                 /Y3 getRandRealy neg def
                 /R3 getRandRealr def
                 /X4 getRandRealx  def
                 /Y4 getRandRealy neg def
                 /R4 getRandRealr def}%
       \pscircle(!X1 Y1){!R1}
       \pscircle(!X2 Y2){!R2}
       \pscircle(!X3 Y3){!R3}
       \pscircle(!X4 Y4){!R4}
        }%
\expandafter\psccurve\collectePoints%
  \endgroup%
  \ignorespaces%
}
\makeatother
\title{L'option \textsf{blendmode} de PSTricks pour réaliser une \oe uvre d'art}
\date{7 septembre 2012}
\begin{document}
\maketitle
\begin{center}
 \begin{pspicture}(-6,-6)(6,6)
    \psgrid[subgriddiv=0,gridcolor=lightgray,griddots=10,gridlabels=0pt]%
    \psStain[style=blendmode3,fillcolor=yellow](-1,-1)
    \psStain[style=blendmode3,fillcolor=cyan](1,-1)
    \psStain[style=blendmode3,fillcolor=magenta](0,1)
 \end{pspicture}
\end{center}
\end{document}

Aucun commentaire:

Enregistrer un commentaire