-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtriangle.ps
87 lines (64 loc) · 1.41 KB
/
triangle.ps
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
%!
%% Triangle of codes
% Define a simple procedure to show a piece of text at a given position
/showat
{
newpath
moveto
show
closepath
} bind def
% Move the origin slightly.
10 10 translate
5 5 scale
/Courier findfont
% Apply a matrix to give the font an 80% aspect ratio
[0.4 0 0 0.5 0 0] makefont
% Make it the current font
setfont
% The 22 valid chars
/ALPHABASE22 (ABCDFGHJKLMNPQRSTVWXYZ) def
% Dummy TLA to be overwritten
/code (***) def
% Set the odometer to 000
/units 0 def
/tens 0 def
/huns 0 def
% Our infections loop from 0 to 99 in increments of 1.
0 1 99
{
/infections exch def
% Deaths loop from 0 to {number of infections} in increments of 1.
0 1 infections
{
/deaths exch def
code 2 ALPHABASE22 units get put
code 1 ALPHABASE22 tens get put
code 0 ALPHABASE22 huns get put
code
% Calculate the coordinates x = deaths, y = 99-infections …
% … and put them on the stack
deaths
99 infections sub
% plot the code
showat
% roll the odometer on
units 1 add dup
22 ge
{
tens 1 add dup
22 ge
{
huns 1 add
/huns def
pop
0
} if
/tens exch def
pop
0
} if
/units exch def
} for
} for
showpage