Retour

transparence.tex

Télécharger le fichier
Image GIF
\documentclass{article}
 
\usepackage{arrayjob}
\usepackage[width=19cm,height=28cm]{geometry}
\usepackage{multido}
\usepackage{pstcol}
\usepackage{pst-char}
% Manuel Luque
% Denis Girou
\input{random}
 
\setlength{\parindent}{0pt}
 
\DeclareFixedFont{\Sf}{T1}{phv}{b}{n}{4cm}
\DeclareFixedFont{\Rm}{T1}{ptm}{m}{n}{4cm}
 
\newarray\colorCyan
\newarray\colorMagenta
\newarray\colorYellow
 
\expandarrayelementtrue
 
\psset{dimen=middle}
 
\makeatletter
 
\def\GraphicBackground(#1,#2){%
% #1 = horizontal size, #2 = vertical size
\multido{\iLineMOne=\z@+\@ne,\iLine=\@ne+\@ne}{#1}{%
  \multido{\iColumnMOne=\z@+\@ne,\iColumn=\@ne+\@ne}{#2}{%
    \setrandim{\pst@dima}{\z@}{0.4pt}%
    \global\colorCyan(\iLine,\iColumn)={\pointless\pst@dima}
    \setrandim{\pst@dimb}{\z@}{0.4pt}%
    \global\colorMagenta(\iLine,\iColumn)={\pointless\pst@dimb}
    \setrandim{\pst@dimc}{\z@}{0.4pt}%
    \global\colorYellow(\iLine,\iColumn)={\pointless\pst@dimc}
    \definecolor{MyColor}{cmyk}%
                {\pointless\pst@dima,\pointless\pst@dimb,\pointless\pst@dimc,0}%
    \psframe[fillstyle=solid,fillcolor=MyColor,linestyle=none]
            (\iLineMOne,\iColumnMOne)(\iLine,\iColumn)}}}
 
\def\GraphicTransparent(#1,#2,#3)(#4,#5){%
% #1, #2, #3 = cyan, magenta and yellow components of the color filter,
% #4, #5 = horizontal and vertical indices
\multido{\iLineMOne=\z@+\@ne,\iLine=\@ne+\@ne}{#4}{%
  \multido{\iColumnMOne=\z@+\@ne,\iColumn=\@ne+\@ne}{#5}{%
    \checkcolorCyan(\iLine,\iColumn)%
    \pst@dima\cachedata pt
    \advance\pst@dima by #1pt
    \ifdim\pst@dima>\@ne pt\pst@dima=\@ne pt\fi
    \checkcolorMagenta(\iLine,\iColumn)%
    \pst@dimb=\cachedata pt
    \advance\pst@dimb by #2pt
    \ifdim\pst@dimb>\@ne pt\pst@dimb=\@ne pt\fi
    \checkcolorYellow(\iLine,\iColumn)%
    \pst@dimc=\cachedata pt
    \advance\pst@dimc by #3pt
    \ifdim\pst@dimc>\@ne pt\pst@dimc=\@ne pt\fi
    \definecolor{MyColor}{cmyk}%
                {\pointless\pst@dima,\pointless\pst@dimb,\pointless\pst@dimc,0}%
    \psframe[linestyle=none,fillstyle=solid,fillcolor=MyColor]
            (\iLineMOne,\iColumnMOne)(\iLine,\iColumn)}}}
 
\def\TextTransparent(#1,#2,#3)(#4,#5)#6{%
% #1, #2, #3 = cyan, magenta and yellow components of the color filter,
% #4, #5 = horizontal and vertical indices,
% #6 = text
\checkcolorCyan(#4,#5)%
\pst@dima\cachedata pt
\advance\pst@dima by #1pt
\ifdim\pst@dima>\@ne pt\pst@dima=\@ne pt\fi
\checkcolorMagenta(#4,#5)%
\pst@dimb=\cachedata pt
\advance\pst@dimb by #2pt
\ifdim\pst@dimb>\@ne pt\pst@dimb=\@ne pt\fi
\checkcolorYellow(#4,#5)%
\pst@dimc=\cachedata pt
\advance\pst@dimc by #3pt
\ifdim\pst@dimc>\@ne pt\pst@dimc=\@ne pt\fi
\definecolor{MyColor}{cmyk}%
            {\pointless\pst@dima,\pointless\pst@dimb,\pointless\pst@dimc,0}%
#6}
 
\def\TestGraphic(#1,#2,#3)(#4,#5)#6#7{%
% #1, #2, #3 = cyan, magenta and yellow components of the color filter,
% #4 = horizontal size, #5 = vertical size, #6 = random seed, #7 = graphic
\definecolor{ColorFilter}{cmyk}{#1,#2,#3,0}%
\dataheight=#4\relax
\pspicture(#4,#5)
  \psset{linestyle=none,fillstyle=solid,fillcolor=ColorFilter}%
  #7
\endpspicture
\hskip 1cm
\pspicture(#4,#5)
  \randomi=#6\relax
  \GraphicBackground(#4,#5)%
\endpspicture
\hskip 1cm
\pspicture(#4,#5)
  \randomi=#6\relax
  \GraphicBackground(#4,#5)%
  \psclip{\pscustom[linestyle=none]{#7}}
    \GraphicTransparent(#1,#2,#3)(#4,#5)%
  \endpsclip
\endpspicture}
 
\def\TestText(#1,#2,#3)(#4,#5)#6#7{%
% #1, #2, #3 = cyan, magenta and yellow components of the color filter,
% #4 = horizontal size, #5 = vertical size, #6 = random seed, #7 = text
\definecolor{ColorFilter}{cmyk}{#1,#2,#3,0}%
\dataheight=#4\relax
\pspicture(#4,#5)
  \randomi=#6\relax
  \GraphicBackground(#4,#5)%
\endpspicture
\hskip 1cm
\pspicture(#4,#5)
  \randomi=#6\relax
  \GraphicBackground(#4,#5)%
  \multido{\iLineMOne=\z@+\@ne,\iLine=\@ne+\@ne}{#4}{%
    \multido{\iColumnMOne=\z@+\@ne,\iColumn=\@ne+\@ne}{#5}{%
      \psclip{\psframe[linestyle=none]
                      (\iLineMOne,\iColumnMOne)(\iLine,\iColumn)}
        \TextTransparent(#1,#2,#3)(\iLine,\iColumn)%
          {\rput(0,0){%
             \pscharpath[linestyle=none,
                         fillstyle=solid,fillcolor=MyColor]{#7}}}
      \endpsclip}}
\endpspicture}
 
\makeatother
 
\begin{document}
 
\TestGraphic(0.8,0.1,0.1)(5,5){574214204}{\pscircle(2.5,2.5){1.75}}
 
\vspace{1cm}
\TestText(0.8,0.1,0.1)(8,6){574214204}{\rput[lb]{37}(2,-0.5){\Sf TeX}}
 
\vspace{1cm}
\TestGraphic(0,0.5,0.4)(5,5){2568792}{\pscurve(0.5,1)(2.5,4.5)(4.5,2)(2,0.5)}
 
\vspace{1cm}
\TestText(0.2,0.4,0.2)(9,6){2568792}
         {\rput[lb](0.5,0.5){\scalebox{0.75 1.8}{\Rm LaTeX}}}
 
\end{document}