\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[a4paper]{geometry}
\usepackage{pst-thick}
\usepackage{pst-slpe,pst-grad,pst-text}
\usepackage{url}
\usepackage{array,booktabs}
\usepackage{graphicx}
\usepackage{frenchle}
\input{random}
% RANDOM.TEX       v.1   (Donald Arseneau)
% Generating "random" numbers in TeX

\newpsstyle{vide}{linestyle=none}
\newdimen{\NumberH}

\def\SinusPhase#1#2#3{%
    /P #1 def % période (10 unités)
    /A #2 def % amplitude
    /F #3 180 div 3.14 mul def
    /O 360 P div def % pulsation 2*pi/P
    /x0 t def
    /y0 t F add O mul sin A mul def % A*sin(O*t)
    /dx dt def
    /dy t F add dt add O mul sin
        t F add O mul sin
        sub
        A mul def }

\date{24 août 2\,007}
\author{Manuel \textsc{Luque}\\
 \texttt{\footnotesize manuel.luque27@gmail.com}}
\title{%PStricks : dans l'épaisseur d'un trait
%\begin{center}
%\psset{unit=0.5}
%\begin{pspicture}(0,1)(20,2)
%\psthick[K=85,stylethick=solide,E=3]{10}{20}{\fonctionSinus{60}{2}}
%\psthick[curveonly,stylecurve2=onlythecurveblue,K=85,E=3]{0}{20}{\fonctionSinus{60}{2}}
%\end{pspicture}
%\end{center}}
\begin{center}
\psset{unit=0.5}
\begin{pspicture}(0,-0.5)(20,1.5)
%\psclip{\psthick[E=2,stylethick=thicklineblue]{0}{10}{\fonctionSinus{20}{1}}}%
%\rput(4.7,1){\includegraphics[scale=0.2]{rat.eps}}
%\endpsclip
\psthick[E=1.2,stylethick=default,plotpoints=720]{1}{19}{\fonctionSinus{10}{1}}%
\rput(0,0){\pstextpath[c]{\parametricplot[linestyle=none]{1}{19}{%
    /P 10 def % période (10 unités)
    /A 1 def % amplitude
    /O 360 P div def
     t O t mul sin A mul
    }}{\textcolor{red}{ Exemples du package \texttt{pst-ticks}-1 }}}
\end{pspicture}
\end{center}}

\begin{document}
\maketitle

\section{Une sinusoïde avec des bandes colorées de façon aléatoire}
\def\couleur{%
        \setrandim{\NumberH}{0pt}{1pt}
        \definecolor{ColorFace}{hsb}{%
        \pointless\NumberH,0.7,1}}

\newpsstyle{aleacolor}{fillstyle=solid,fillcolor=ColorFace,plotpoints=360}

\begin{center}
\psset{unit=0.5}
\begin{pspicture}(0,-5)(30,5)
\multido{\i=0+1,\I=1+1}{30}{%
\couleur%
    \psthick[E=2,stylethick=aleacolor]{\i}{\I}{\SinusPhase{10}{2}{0}}
 }
\end{pspicture}
\end{center}

Définition aléatoire d'une couleur, grâce au package \texttt{random.tex} de Donald Arseneau, puis du style associé~:~
\verb+stylethick=aleacolor+.

\begin{verbatim}
\def\couleur{%
        \setrandim{\NumberH}{0pt}{1pt}
        \definecolor{ColorFace}{hsb}{%
        \pointless\NumberH,0.7,1}}

\newpsstyle{aleacolor}{fillstyle=solid,fillcolor=ColorFace,plotpoints=360}

\begin{center}
\psset{unit=0.5}
\begin{pspicture}(0,-4)(30,4)
\multido{\i=0+1,\I=1+1}{30}{%
\couleur%
    \psthick[E=2,stylethick=aleacolor]{\i}{\I}{\SinusPhase{10}{2}{0}}
 }
\end{pspicture}
\end{center}
\end{verbatim}
\section{Lemniscate en n\oe{}ud papillon et aux petits pois}
\begin{verbatim}
\def\Lemniscate#1#2{% {A}{P}
    /A #1 def % amplitude
    /P #2 def % Période
    /O 360 P div def % pulsation 2*pi/P
    /x0 t O mul cos A mul 2 mul def % x=2*a*cos(O*t)
    /y0 t O mul 2 mul sin A mul def % y=a*sin*(2*O*t)
    /dx t dt add O mul cos A mul 2 mul
        x0 sub def
     /dy t dt add O mul 2 mul sin A mul
         y0 sub def}
\end{verbatim}
\def\Lemniscate#1#2{% {a}{P}
    /A #1 def %
    /P #2 def %
    /O 360 P div def % pulsation 2*pi/P
    /x0 t O mul cos A mul 2 mul def
    /y0 t O mul 2 mul sin A mul def
    /dx t dt add O mul cos A mul 2 mul
        x0 sub def
     /dy t dt add O mul 2 mul sin A mul
         y0 sub def}
\begin{center}
\begin{pspicture}(-6,-3)(6,3)
\psframe(-6,-3)(6,3)
\psthick[linestyle=none]{0}{360}{\Lemniscate{2.5}{360}}
\psclip{\psthick[stylethick=vide]{180}{360}{\Lemniscate{2.5}{360}}}
   \psthick[stylethick=thicklineblue]{80}{100}{\Lemniscate{2.5}{360}}
\endpsclip
    \psthick[curveonly]{0}{360}{\Lemniscate{2.5}{360}}
\psaxes(0,0)(-6,-3)(6,3)
\end{pspicture}
\end{center}
\begin{center}
\begin{pspicture}(-3,-3)(3,3)
\psframe(-6,-3)(6,3)
\psthick[linestyle=none,E=0.5]{0}{360}{\Lemniscate{2.5}{360}}
\psclip{\psthick[stylethick=vide,E=0.5]{0}{360}{\Lemniscate{2.5}{360}}}
   \multido{\nx=-6+0.5}{30}{%
      \multido{\ny=-6+0.5}{30}{%
       \pscircle*[linecolor=green](\nx,\ny){0.2}
   }}
\endpsclip
    \psthick[curveonly,E=0.5]{0}{360}{\Lemniscate{2.5}{360}}
\psaxes(0,0)(-6,-3)(6,3)
\end{pspicture}
\end{center}
\begin{verbatim}
\begin{center}
\begin{pspicture}(-6,-3)(6,3)
\psframe(-6,-3)(6,3)
\psthick[linestyle=none]{0}{360}{\Lemniscate{2.5}{360}}
\psclip{\psthick[stylethick=vide]{180}{360}{\Lemniscate{2.5}{360}}}
   \psthick[stylethick=thicklineblue]{80}{100}{\Lemniscate{2.5}{360}}
\endpsclip
    \psthick[curveonly]{0}{360}{\Lemniscate{2.5}{360}}
\psaxes(0,0)(-6,-3)(6,3)
\end{pspicture}
\end{center}
\begin{center}
\begin{pspicture}(-3,-3)(3,3)
\psframe(-6,-3)(6,3)
\psthick[linestyle=none,E=0.5]{0}{360}{\Lemniscate{2.5}{360}}
\psclip{\psthick[stylethick=vide,E=0.5]{0}{360}{\Lemniscate{2.5}{360}}}
   \multido{\nx=-6+0.5}{30}{%
      \multido{\ny=-6+0.5}{30}{%
       \pscircle*[linecolor=green](\nx,\ny){0.2}
   }}
\endpsclip
    \psthick[curveonly,E=0.5]{0}{360}{\Lemniscate{2.5}{360}}
\psaxes(0,0)(-6,-3)(6,3)
\end{pspicture}
\end{center}
\end{verbatim}
\clearpage
\section{Lemniscate à échelons avec fourmis}
\begin{center}
\begin{pspicture}(-6,-3)(6,3)
\psframe(-6,-3)(6,3)
\psthick[stylethick=thicklineblue,linestyle=none]{0}{360}{\Lemniscate{2.5}{360}}
\psthick[curveonly,stylecurve2=onlythecurveblue,stylecurve1=onlythecurveblue]{0}{360}{\Lemniscate{2.5}{360}}
\psthick[stylethick=thicklineblue,linestyle=none]{260}{280}{\Lemniscate{2.5}{360}}
\psthick[curveonly,stylecurve2=onlythecurveblue,stylecurve1=onlythecurveblue]{260}{280}{\Lemniscate{2.5}{360}}
\multido{\i=0+10}{36}{%
\pnode(!/t \i\space def
    /E 1 def
    /K 0 def
    /dt 0.01 def
    \Lemniscate{2.5}{360}
    /ds dx dup mul dy dup mul add sqrt def
    /dx dx ds div def
    /dy dy ds div def
    /dx' K cos dx mul K sin dy mul sub def
    /dy' K sin dx mul K cos dy mul add def
    /nx E 2 div dy' mul neg def % normale x
    /ny E 2 div dx' mul def % normale y
    /x1 x0 nx add def
    /y1 y0 ny add def
      x1 y1){A}
\pnode(!
    /x2 x0 nx sub def
    /y2 y0 ny sub def
      x2 y2){B}
\ifnum\i=90{}\else
\psdot[linecolor=blue](A)
\psdot[linecolor=blue](B)
\psline(A)(B)\fi}
\rput(-4.8,1.5){\includegraphics[scale=0.1]{fourmi1.eps}}
\rput(0,0){\includegraphics[scale=0.72]{fourmi2.eps}}
\end{pspicture}
\end{center}
\begin{verbatim}
\begin{pspicture}(-6,-3)(6,3)
\psframe(-6,-3)(6,3)
\psthick[stylethick=thicklineblue]{0}{360}{\Lemniscate{2.5}{360}}
\multido{\i=0+10}{36}{%
\pnode(!/t \i\space def
    /E 1 def
    /K 0 def
    /dt 0.01 def
    \Lemniscate{2.5}{360}
    /ds dx dup mul dy dup mul add sqrt def
    /dx dx ds div def
    /dy dy ds div def
    /dx' K cos dx mul K sin dy mul sub def
    /dy' K sin dx mul K cos dy mul add def
    /nx E 2 div dy' mul neg def % normale x
    /ny E 2 div dx' mul def % normale y
    /x1 x0 nx add def
    /y1 y0 ny add def
      x1 y1){A}
\psdot[linecolor=blue](A)
\pnode(!
    /x2 x0 nx sub def
    /y2 y0 ny sub def
      x2 y2){B}
\psdot[linecolor=blue](B)
\psline(A)(B)}
\end{pspicture}
\end{verbatim}
\clearpage
\section{Courbes de Lissajous}
\def\Lissajous#1#2#3#4#5{% {a}{b}{p}{q}{F}
    /A #1 def %
    /B #2 def
    /P #3 def %
    /Q #4 def
    /F #5 def
%    x=a*sin(p*t)
%    y=b*sin(q*t+F)
    /x0 t P mul sin A mul def
    /y0 t Q mul F add sin B mul def
    /dx t dt add P mul sin A mul
        x0 sub def
     /dy t dt add Q mul F add sin B mul
         y0 sub def}
\begin{center}
\psset{unit=0.6}
\begin{pspicture}(-6,-3)(6,3)
\psframe(-6,-3)(6,3)
\psthick[E=0.15,linestyle=none]{0}{360}{\Lissajous{5}{2.5}{5}{4}{0}}%
\psthick[curveonly,E=0.15]{0}{360}{\Lissajous{5}{2.5}{5}{4}{0}}%
\psaxes(0,0)(-6,-3)(6,3)
\end{pspicture}
\hfill
\begin{pspicture}(-6,-3)(6,3)
\psframe(-6,-3)(6,3)
\psthick[E=0.25,linestyle=none]{0}{360}{\Lissajous{5}{2.5}{3}{2}{0}}%
\psthick[curveonly,E=0.25]{0}{360}{\Lissajous{5}{2.5}{3}{2}{0}}%
\psaxes(0,0)(-6,-3)(6,3)
\end{pspicture}
\end{center}
{\small
\begin{verbatim}
\def\Lissajous#1#2#3#4#5{% {a}{b}{p}{q}{F}
    /A #1 def %
    /B #2 def
    /P #3 def %
    /Q #4 def
    /F #5 def % phi en degrés
    /x0 t P mul sin A mul def       %    x=a*sin(p*t)
    /y0 t Q mul F add sin B mul def %    y=b*sin(q*t+F)
    /dx t dt add P mul sin A mul
        x0 sub def
     /dy t dt add Q mul F add sin B mul
         y0 sub def}
\begin{pspicture}(-6,-3)(6,3)
\psthick[E=0.15,linestyle=none]{0}{360}{\Lissajous{5}{2.5}{5}{4}{0}}%
\psthick[curveonly,E=0.15]{0}{360}{\Lissajous{5}{2.5}{5}{4}{0}}%
\end{pspicture}
\begin{pspicture}(-6,-3)(6,3)
\psthick[E=0.25,linestyle=none]{0}{360}{\Lissajous{5}{2.5}{3}{2}{0}}%
\psthick[curveonly,E=0.25]{0}{360}{\Lissajous{5}{2.5}{3}{2}{0}}%
\end{pspicture}
\end{verbatim}}
\end{document}
