summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/fonts/source/public/knuth-local/random.mf
blob: cc433a8d1fb44c3ed86b648983bc588b9e7b19a3 (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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
% Font for examples in Chapter 21 of The METAFONTbook

font_size 10pt#;
mode_setup;

font_identifier "RANDOM";
font_coding_scheme "PI";

% uniforms (characters 0--9)
randomseed:=3.14159;
for code=0 upto 9:
beginchar(code,10pt#,10pt#,0);
pickup pencircle scaled .3pt; draw unitsquare scaled w;
pickup pencircle scaled 1pt;
for k=1 upto 100: drawdot(uniformdeviate w,uniformdeviate w); endfor
endchar;
endfor

% normals (characters 10--19)
randomseed:=3.14159;
for code=10 upto 19:
beginchar(code,10pt#,10pt#,0);
pickup pencircle scaled .3pt; draw unitsquare scaled w;
pickup pencircle scaled 1pt;
for k=1 upto 100: drawdot(1/6w*normaldeviate+.5w,1/6w*normaldeviate+.5w); endfor
endchar;
endfor

% both (characters 20--29)
randomseed:=3.14159;
for code=20 upto 29:
beginchar(code,10pt#,10pt#,0);
pickup pencircle scaled .3pt; draw unitsquare scaled w;
pickup pencircle scaled 1pt;
for k=1 upto 100: drawdot(uniformdeviate w,1/6w*normaldeviate+.5w); endfor
endchar;
endfor

% METAFONT logo (characters 30--109)
randomseed:=ASCII"M"+epsilon*ASCII"F";
vardef noise=normaldeviate*craziness enddef;

ht#:=6pt#;
xgap#:=0.6pt#;
u#:=4/9pt#;
s#:=0;
o#:=1/9pt#;
px#:=2/3pt#;
ygap#:=xgap#;
leftstemloc#:=2.5u#+s#;
barheight#:=.45ht#;
define_pixels(s,u,xgap,ygap,leftstemloc,barheight);
py#:=.9px#; define_blacker_pixels(px,py);
pickup pencircle xscaled px yscaled py; logo_pen:=savepen;
define_corrected_pixels(o);

def beginlogochar(expr c,n) =
 beginchar(incr code,n*u#+2s#,ht#,0); pickup logo_pen enddef;

def NN=
beginlogochar("N",15);
x1=leftstemloc+noise;
x2=leftstemloc+noise;
x4=w-leftstemloc+noise;
x5=w-leftstemloc+noise;
bot y1=noise-o;
top y2=h+o+noise;
y3=y4+ygap+noise;
bot y4=noise-o;
top y5=h+o+noise;
z3=whatever[z4,z5];
draw z1--z2--z3; draw z4--z5; labels(1,2,3,4,5); endchar;
enddef;

def MM=
beginlogochar("M",18);
x1=leftstemloc+noise;
x2=leftstemloc+noise;
x3=.5w+noise;
x4=w-leftstemloc+noise;
x5=w-leftstemloc+noise;
bot y1=noise-o;
top y2=h+o+noise;
bot y3=ygap+noise;
top y4=h+o+noise;
bot y5=noise-o;
draw z1--z2--z3--z4--z5; labels(1,2,3,4,5); endchar;
enddef;

def EE=
beginlogochar("E",14);
x1=leftstemloc+noise;
x3=leftstemloc+noise;
x4=w-leftstemloc+o+noise;
x5=w-leftstemloc+o-xgap+noise;
x6=w-leftstemloc+o+noise;
bot y1=noise;
y2=barheight+noise;
top y3=h+noise;
top y4=h+noise;
y5=barheight+noise;
bot y6=noise;
z2=whatever[z1,z3];
draw z6--z1--z3--z4; draw z2--z5; labels(1,2,3,4,5,6); endchar;
enddef;

def FF=
beginlogochar("F",14);
x1=leftstemloc+noise;
x3=leftstemloc+noise;
x4=w-leftstemloc+o+noise;
x5=w-leftstemloc+o-xgap+noise;
bot y1=noise-o;
y2=barheight+noise;
top y3=h+noise;
top y4=h+noise;
y5=barheight+noise;
bot y6=noise;
z2=whatever[z1,z3];
draw z1--z3--z4; draw z2--z5; labels(1,2,3,4,5); endchar;
enddef;

def TT=
beginlogochar("T",13);
lft x1=noise;
rt x2=w+noise;
x3=.5w+noise;
x4=.5w+noise;
top y1=h+noise;
top y2=h+noise;
bot y4=noise-o;
z3=whatever[z1,z2];
draw z1--z2; draw z3--z4; labels(1,2,3,4); endchar;
enddef;

def AA=
beginlogochar("A",15);
x1=.5w+noise;
x2'=leftstemloc+noise;
x3'=w-leftstemloc+noise;
x4=leftstemloc+noise;
x5=w-leftstemloc+noise;
top y2'=h+o+noise;
top y3'=h+o+noise;
y2=barheight+noise;
y3=barheight+noise;
bot y4=noise-o;
bot y5=noise-o;
z1=whatever[z2',z3'];
z2=whatever[z4,z2'];
z3=whatever[z5,z3'];
draw z4--z2--z3--z5;
draw z2{z2'-z2}...z2+.8(z2'-z2)-.2(z2'-z1){z1-z2}
 ...z1{z3'-z2'}...z3+.8(z3'-z3)-.2(z3'-z1){z3-z1}...z3{z3-z3'};
labels(1,2,3,4,5,2',3'); endchar;
enddef;

def OO=
beginlogochar("O",15);
x1'=1.5u+s+noise;
x2'=1.5u+s+noise;
x3'=w-1.5u-s+noise;
x4'=w-1.5u-s+noise;
bot y1'=noise-o;
top y2'=h+o+noise;
top y3'=h+o+noise;
bot y4'=noise-o;
z1=.5[z1',z2']; z2=.5[z2',z3']; z3=.5[z3',z4']; z4=.5[z4',z1'];
draw z2{z2'-z3'}...z2+.8(z2'-z2)-.2(z2'-z1){z1-z2}
 ...z1{z1'-z2'}...z1+.8(z1'-z1)-.2(z1'-z4){z4-z1}
 ...z4{z4'-z1'}...z4+.8(z4'-z4)-.2(z4'-z3){z3-z4}
 ...z3{z3'-z4'}...z3+.8(z3'-z3)-.2(z3'-z2){z2-z3}...cycle;
labels(1,2,3,4,5,2',3'); endchar;
enddef;


code:=29;
for c=10 downto 1:craziness:=c*.05pt;
 MM; EE; TT; AA; FF; OO; NN; TT; endfor

% histogram (character 126)
randomseed:=0;
beginchar(126,24pt#,10pt#,0);
%pickup pencircle scaled .3pt; draw unitsquare xscaled w yscaled h;
 numeric count[]; pickup pencircle scaled 1pt;
for n:=1 upto 100: x:=normaldeviate*4pt+12pt;
y:=floor(x/pt); if unknown count[y]: count[y]:=-1; fi
drawdot(x,pt*incr count[y]); endfor endchar;

% skyline (character 127)
randomseed:=2.71828;
beginchar(127,100pt#,10pt#,0);
for n:=0 upto 99:
fill unitsquare xscaled 1pt yscaled uniformdeviate h shifted (n*pt,0);
endfor
endchar;

bye