summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/latex-graphics-companion/4-10-5.ltx
blob: b4ede3f1ee5d4849d66613ad16aed4e811f456cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
\documentclass{ppex}
\nonstopmode
\usepackage {pstcol,multido}
\pagestyle{empty}
\setlength\textwidth{183.0pt}
\begin{document}
\ResetPreambleCommands
\ReadyForTheFray
\usepackage {pstcol,multido}
\input random.tex
\newdimen\X \newdimen\Y\newdimen\Coor
% #1 is number of steps
\newcommand{\RandomWalk}[1]{%
\setrandim\X{0pt}{1pt}
\setrandim\Y{0pt}{1pt}
\psdots[dotstyle=*,dotsize=6pt]
  (\pointless\X,\pointless\Y)
\pscustom{%
 \moveto(\pointless\X,\pointless\Y)
 \multido{\i=1+1}{#1}{%
  \MoveCoordinate{\X}
  \MoveCoordinate{\Y}
  \lineto(\pointless\X,\pointless\Y)}}}
% Computation of new horizontal
% or vertical position of point
\newcommand{\MoveCoordinate}[1]{%
 \setrandim\Coor{-0.03pt}{0.03pt}
 \advance #1 by \Coor
 \ifdim#1>1pt #1=1pt \fi
 \ifdim#1<0pt #1=0pt \fi
}
\newcommand{\randomdemo}[2]{{%
 \psframe[linewidth=0.6mm](1,1)
 \rput(#1,#2){\RandomWalk{300}}
 \psset{linecolor=red}
 \rput(#1,#2){\RandomWalk{200}}
 \psset{linecolor=green}
 \rput(#1,#2){\RandomWalk{100}}
}}
\psset{unit=5,dimen=middle}
\framebox{\begin{pspicture}(1,3)
 \randomdemo{0}{0}
 \randomdemo{0}{1}
 \randomdemo{0}{2}
\end{pspicture}}
\end{document}