Debian Codegraph @

texmf-dist/fonts/source/public/knuth-local/random.mf

raw
1 % Font for examples in Chapter 21 of The METAFONTbook
2
3 font_size 10pt#;
4 mode_setup;
5
6 font_identifier "RANDOM";
7 font_coding_scheme "PI";
8
9 % uniforms (characters 0--9)
10 randomseed:=3.14159;
11 for code=0 upto 9:
12 beginchar(code,10pt#,10pt#,0);
13 pickup pencircle scaled .3pt; draw unitsquare scaled w;
14 pickup pencircle scaled 1pt;
15 for k=1 upto 100: drawdot(uniformdeviate w,uniformdeviate w); endfor
16 endchar;
17 endfor
18
19 % normals (characters 10--19)
20 randomseed:=3.14159;
21 for code=10 upto 19:
22 beginchar(code,10pt#,10pt#,0);
23 pickup pencircle scaled .3pt; draw unitsquare scaled w;
24 pickup pencircle scaled 1pt;
25 for k=1 upto 100: drawdot(1/6w*normaldeviate+.5w,1/6w*normaldeviate+.5w); endfor
26 endchar;
27 endfor
28
29 % both (characters 20--29)
30 randomseed:=3.14159;
31 for code=20 upto 29:
32 beginchar(code,10pt#,10pt#,0);
33 pickup pencircle scaled .3pt; draw unitsquare scaled w;
34 pickup pencircle scaled 1pt;
35 for k=1 upto 100: drawdot(uniformdeviate w,1/6w*normaldeviate+.5w); endfor
36 endchar;
37 endfor
38
39 % METAFONT logo (characters 30--109)
40 randomseed:=ASCII"M"+epsilon*ASCII"F";
41 vardef noise=normaldeviate*craziness enddef;
42
43 ht#:=6pt#;
44 xgap#:=0.6pt#;
45 u#:=4/9pt#;
46 s#:=0;
47 o#:=1/9pt#;
48 px#:=2/3pt#;
49 ygap#:=xgap#;
50 leftstemloc#:=2.5u#+s#;
51 barheight#:=.45ht#;
52 define_pixels(s,u,xgap,ygap,leftstemloc,barheight);
53 py#:=.9px#; define_blacker_pixels(px,py);
54 pickup pencircle xscaled px yscaled py; logo_pen:=savepen;
55 define_corrected_pixels(o);
56
57 def beginlogochar(expr c,n) =
58 beginchar(incr code,n*u#+2s#,ht#,0); pickup logo_pen enddef;
59
60 def NN=
61 beginlogochar("N",15);
62 x1=leftstemloc+noise;
63 x2=leftstemloc+noise;
64 x4=w-leftstemloc+noise;
65 x5=w-leftstemloc+noise;
66 bot y1=noise-o;
67 top y2=h+o+noise;
68 y3=y4+ygap+noise;
69 bot y4=noise-o;
70 top y5=h+o+noise;
71 z3=whatever[z4,z5];
72 draw z1--z2--z3; draw z4--z5; labels(1,2,3,4,5); endchar;
73 enddef;
74
75 def MM=
76 beginlogochar("M",18);
77 x1=leftstemloc+noise;
78 x2=leftstemloc+noise;
79 x3=.5w+noise;
80 x4=w-leftstemloc+noise;
81 x5=w-leftstemloc+noise;
82 bot y1=noise-o;
83 top y2=h+o+noise;
84 bot y3=ygap+noise;
85 top y4=h+o+noise;
86 bot y5=noise-o;
87 draw z1--z2--z3--z4--z5; labels(1,2,3,4,5); endchar;
88 enddef;
89
90 def EE=
91 beginlogochar("E",14);
92 x1=leftstemloc+noise;
93 x3=leftstemloc+noise;
94 x4=w-leftstemloc+o+noise;
95 x5=w-leftstemloc+o-xgap+noise;
96 x6=w-leftstemloc+o+noise;
97 bot y1=noise;
98 y2=barheight+noise;
99 top y3=h+noise;
100 top y4=h+noise;
101 y5=barheight+noise;
102 bot y6=noise;
103 z2=whatever[z1,z3];
104 draw z6--z1--z3--z4; draw z2--z5; labels(1,2,3,4,5,6); endchar;
105 enddef;
106
107 def FF=
108 beginlogochar("F",14);
109 x1=leftstemloc+noise;
110 x3=leftstemloc+noise;
111 x4=w-leftstemloc+o+noise;
112 x5=w-leftstemloc+o-xgap+noise;
113 bot y1=noise-o;
114 y2=barheight+noise;
115 top y3=h+noise;
116 top y4=h+noise;
117 y5=barheight+noise;
118 bot y6=noise;
119 z2=whatever[z1,z3];
120 draw z1--z3--z4; draw z2--z5; labels(1,2,3,4,5); endchar;
121 enddef;
122
123 def TT=
124 beginlogochar("T",13);
125 lft x1=noise;
126 rt x2=w+noise;
127 x3=.5w+noise;
128 x4=.5w+noise;
129 top y1=h+noise;
130 top y2=h+noise;
131 bot y4=noise-o;
132 z3=whatever[z1,z2];
133 draw z1--z2; draw z3--z4; labels(1,2,3,4); endchar;
134 enddef;
135
136 def AA=
137 beginlogochar("A",15);
138 x1=.5w+noise;
139 x2'=leftstemloc+noise;
140 x3'=w-leftstemloc+noise;
141 x4=leftstemloc+noise;
142 x5=w-leftstemloc+noise;
143 top y2'=h+o+noise;
144 top y3'=h+o+noise;
145 y2=barheight+noise;
146 y3=barheight+noise;
147 bot y4=noise-o;
148 bot y5=noise-o;
149 z1=whatever[z2',z3'];
150 z2=whatever[z4,z2'];
151 z3=whatever[z5,z3'];
152 draw z4--z2--z3--z5;
153 draw z2{z2'-z2}...z2+.8(z2'-z2)-.2(z2'-z1){z1-z2}
154 ...z1{z3'-z2'}...z3+.8(z3'-z3)-.2(z3'-z1){z3-z1}...z3{z3-z3'};
155 labels(1,2,3,4,5,2',3'); endchar;
156 enddef;
157
158 def OO=
159 beginlogochar("O",15);
160 x1'=1.5u+s+noise;
161 x2'=1.5u+s+noise;
162 x3'=w-1.5u-s+noise;
163 x4'=w-1.5u-s+noise;
164 bot y1'=noise-o;
165 top y2'=h+o+noise;
166 top y3'=h+o+noise;
167 bot y4'=noise-o;
168 z1=.5[z1',z2']; z2=.5[z2',z3']; z3=.5[z3',z4']; z4=.5[z4',z1'];
169 draw z2{z2'-z3'}...z2+.8(z2'-z2)-.2(z2'-z1){z1-z2}
170 ...z1{z1'-z2'}...z1+.8(z1'-z1)-.2(z1'-z4){z4-z1}
171 ...z4{z4'-z1'}...z4+.8(z4'-z4)-.2(z4'-z3){z3-z4}
172 ...z3{z3'-z4'}...z3+.8(z3'-z3)-.2(z3'-z2){z2-z3}...cycle;
173 labels(1,2,3,4,5,2',3'); endchar;
174 enddef;
175
176
177 code:=29;
178 for c=10 downto 1:craziness:=c*.05pt;
179 MM; EE; TT; AA; FF; OO; NN; TT; endfor
180
181 % histogram (character 126)
182 randomseed:=0;
183 beginchar(126,24pt#,10pt#,0);
184 %pickup pencircle scaled .3pt; draw unitsquare xscaled w yscaled h;
185 numeric count[]; pickup pencircle scaled 1pt;
186 for n:=1 upto 100: x:=normaldeviate*4pt+12pt;
187 y:=floor(x/pt); if unknown count[y]: count[y]:=-1; fi
188 drawdot(x,pt*incr count[y]); endfor endchar;
189
190 % skyline (character 127)
191 randomseed:=2.71828;
192 beginchar(127,100pt#,10pt#,0);
193 for n:=0 upto 99:
194 fill unitsquare xscaled 1pt yscaled uniformdeviate h shifted (n*pt,0);
195 endfor
196 endchar;
197
198 bye