summaryrefslogtreecommitdiff
path: root/dviware/psprint/unix/random.ps
blob: 3e69f4c16d8063f4ab9777e4ac2b5d7a10d2386c (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
% This file is inserted into the PSPRINT User Guide using \special.
% It plots 100 random dots.

72 72 scale                   % units now inches

% uncomment the next line if you want to "psprint random.ps"
% 2 2 translate

/xlen 1.3 def                 % length of x axis
/ylen 1.3 def                 % length of y axis
newpath
0 0 moveto xlen 0 rlineto     % x axis
0 0 moveto 0 ylen rlineto     % y axis
.01 setlinewidth
stroke                        % draw axes

/fontsize 10 72 div def       % use 10pt font for labels
/Helvetica findfont
fontsize scalefont setfont
fontsize neg dup moveto (0) show
fontsize neg ylen moveto (1) show
xlen fontsize 2 div add fontsize neg moveto (1) show

% draw 100 random dots

/randlim 2 31 exp 1 sub def   % rand will return integer from 0 to 2^31 - 1
newpath
1 1 100                              % do the following procedure 100 times
{ pop                                % we don't use control variable
  /x rand randlim div xlen mul def   % x is real number from 0 to xlen
  /y rand randlim div ylen mul def   % y is real number from 0 to ylen
  x y moveto
  x y lineto                         % create a dot
} for
1 setlinecap                         % round line ends
.04 setlinewidth                     % diameter of dots
stroke                               % draw all dots

showpage