diff options
Diffstat (limited to 'Master/texmf-dist/doc/generic/pstricks/voss/bsp55.tex')
-rw-r--r-- | Master/texmf-dist/doc/generic/pstricks/voss/bsp55.tex | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/generic/pstricks/voss/bsp55.tex b/Master/texmf-dist/doc/generic/pstricks/voss/bsp55.tex new file mode 100644 index 00000000000..6c9871a5f59 --- /dev/null +++ b/Master/texmf-dist/doc/generic/pstricks/voss/bsp55.tex @@ -0,0 +1,50 @@ +\documentclass{article} + +\usepackage{pstricks} % To use the standard "color" package with PSTricks +\usepackage{multido} +\input{random.tex} % From Donald Arseneau (on macros/generic on CTAN) + +\newdimen\dX +\newdimen\dY +\newdimen\Coor + +% Random walk in the unit square (#1 = number of steps) +\def\RandomWalk#1{% +\setrandim\dX{0pt}{1pt} +\setrandim\dY{0pt}{1pt} +\psdot[dotstyle=*,dotsize=6pt](\pointless\dX,\pointless\dY) % Initial point +\pscustom{% + \moveto(\pointless\dX,\pointless\dY) % Move to initial point + \multido{\i=1+1}{#1}{% + \MoveCoordinate{\dX} + \MoveCoordinate{\dY} + \lineto(\pointless\dX,\pointless\dY)}}} % Line between old and new position + +% Computation of new horizontal or vertical position of point +\def\MoveCoordinate#1{% +\setrandim\Coor{-0.06pt}{0.06pt} % The move +\advance #1 by \Coor % New position +% To stay in the square... +\ifdim#1>1pt + #1=1pt +\fi +\ifdim#1<0pt + #1=0pt +\fi} + +\pagestyle{empty} +\parindent=0pt + +\begin{document} + +\psset{unit=11,dimen=middle} +\begin{pspicture}(1,1) + \psframe[linewidth=0.1pt](1,1) + \RandomWalk{300} + \psset{linecolor=red} + \RandomWalk{300} + \psset{linecolor=green} + \RandomWalk{300} +\end{pspicture} + +\end{document} |