Debian Codegraph @

texmf-dist/metapost/fetamont/ffmconstructions.mp

raw
1 % !TEX program = mpost
2 input TEX;
3 TEXPRE("%&latex" & char(10) & "\documentclass{article}\begin{document}");
4 TEXPOST("\end{document}");
5 outputtemplate := "%j-%c.mps";
6
7 %an arc is kind of a quarter of a skewed superellipse
8 vardef arc(expr zi,diri,zj,dirj) =
9 zi{diri}...
10 begingroup
11 save corner,zij;
12 pair corner,zij;
13 corner=zi+whatever*diri=zj+whatever*dirj;
14 zij=zi
15 +superness*(corner-zi)
16 +(1-superness)*(zj-corner);
17 zij
18 endgroup{zj-zi}
19 ...zj{dirj}
20 enddef;
21
22 %two concatenated arcs
23 def half(expr zi,diri,zj,dirj,zk,dirk) =
24 arc(zi,diri,zj,dirj)
25 & arc(zj,dirj,zk,dirk)
26 enddef;
27
28 %two concatenated halfs
29 def full(expr zi,diri,zj,dirj,zk,dirk,zl,dirl) =
30 half(zi,diri,zj,dirj,zk,dirk)
31 & half(zk,dirk,zl,dirl,zi,diri)
32 enddef;
33
34 %----------------------------------------------------------
35 beginfig(0);
36 u:=1cm;
37 numeric superness;
38 pair zi,zj,zij,diri, dirj,corner,center;
39 superness=.75;
40 zi=(0,0);
41 zj=(5u,4u);
42 diri=(.1u,1u);
43 dirj=(.7u,.05u);
44 corner=zi+whatever*diri=zj+whatever*dirj;
45 center=zi+whatever*dirj=zj+whatever*diri;
46 z1=.5[center,zj];
47 z2=.5[zj,corner];
48 z3=.5[corner,zi];
49 z4=.5[zi,center];
50 pickup pencircle scaled 2.5bp;
51 draw full(z1,diri,z2,-dirj,z3,-diri,z4,dirj) withcolor .8white;
52 draw arc(z3,diri,z2,dirj) withcolor .6white;
53 pickup pencircle scaled .5bp
54 draw zi--center--zj--corner--cycle;
55 label.lrt(TEX("arc"), (z3+superness*(corner-z3)+(1-superness)*(z2-corner)));
56 label.bot(TEX("skewed superellipse"), z4);
57 endfig;
58 %----------------------------------------------------------
59 beginfig(1);
60 u:=1cm;
61 superness:=.75;
62 pair zi,zj,zij,diri, dirj, corner, center;
63 zi=(0,0);
64 zj=(5u,4u);
65 diri=(.1u,1u);
66 dirj=(.7u,.05u);
67 corner=zi+whatever*diri=zj+whatever*dirj;
68 center=zi+whatever*dirj=zj+whatever*diri;
69 zij=superness[center,corner];
70 z1=zi+whatever*diri=zij+whatever*(zj-zi);
71 z2=zj+whatever*dirj=zij+whatever*(zj-zi);
72 pickup pencircle scaled 5bp
73 draw zi{diri}
74 ...(zi
75 +superness*(corner-zi)
76 -(1-superness)*(corner-zj))
77 {zj-zi}
78 ...zj{dirj}
79 withcolor .8white;
80 pickup pencircle scaled .5bp
81 draw zi -- zj;
82 draw zi -- center -- zj -- corner -- cycle;
83 draw center -- corner;
84 drawarrow zi -- (zi+diri);
85 drawarrow zj -- (zj+dirj);
86 drawarrow zi -- (zi+(1-superness)*(zj-corner));
87 drawarrow (zi+(1-superness)*(zj-corner)) -- zij;
88 draw z1 -- z2;
89 label.bot(TEX("$z_i$"), zi);
90 label.top(TEX("$z_j$"), zj);
91 label.lft(TEX("$\mathrm{corner}$"), corner);
92 label.rt(TEX("$\mathrm{center}$"), center);
93 label.lft(TEX("$\mathrm{dir}_i$"), (zi+diri));
94 label.bot(TEX("$\mathrm{dir}_j$"), (zj+dirj));
95 label.top(TEX("$z_{ij}$"), zij);
96 label.lrt(TEX("$(1-\mathrm{superness})\cdot(z_j-\mathrm{corner})$"), (zi+.5*(1-superness)*(zj-corner)));
97 label.rt(TEX("$\mathrm{superness}\cdot(\mathrm{corner}-z_i)$"), .6[(zi+(1-superness)*(zj-corner)),zij]);
98 endfig;
99 %----------------------------------------------------------
100 beginfig(2);
101 u:=.5cm;
102 noise:=0;
103 h:=6u;
104 barheight:=.45h;
105 superness:=.8;
106 w:=20/3*u;
107 leftstemloc:=10/9*u;
108 o:=u/9;
109 px:=2/3*u;
110 py:=.9px;
111 pair randrt;
112 randrt:=(1,0);
113 pickup pencircle xscaled px yscaled py;
114 x1=leftstemloc+noise;
115 x2=leftstemloc+noise;
116 x3=.5w+noise;
117 w-x4=leftstemloc+noise;
118 w-x5=leftstemloc+noise;
119 bot y1=noise-o;
120 y2=barheight+noise;
121 top y3=h+o; %no noise because of Aring
122 y4=barheight+noise;
123 bot y5=noise-o;
124 bot y6=0; %no noise
125 z6=whatever[z4,z5];
126 draw z1--z2
127 & half(z2,z2-z1,z3,randrt,z4,z5-z4)
128 & z4--z5
129 withcolor .8white;
130 draw z2--z4 withcolor .8white;
131 pickup pencircle scaled .5bp
132 draw (0,0) -- (w,0) -- (w,h) -- (0,h) -- cycle;
133 dotlabel.top(TEX("anchor top (base)"), (.5w,h));
134 endfig;
135 %----------------------------------------------------------
136 beginfig(3);
137 u:=.5cm;
138 noise:=0;
139 h:=6.5u;
140 x_ht:=4.5u;
141 barheight:=.45h;
142 superness:=.8;
143 w:=28/9*u;
144 leftstemloc:=10/9*u;
145 o:=u/9;
146 px:=2/3*u;
147 py:=.9px;
148 pair randrt;
149 randrt:=(1,0);
150 pickup pencircle xscaled px yscaled py;
151 lft x1=noise;
152 x2=.5w+noise;
153 rt x3=w+noise;
154 bot y1=.2[x_ht,h]+noise;
155 bot y3=.2[x_ht,h]+noise;
156 top y2=h+o+noise;
157 draw z1--z2--z3 withcolor .8white;
158 pickup pencircle scaled .5bp
159 draw (0,0) -- (w,0) -- (w,h) -- (0,h) -- cycle;
160 dotlabel.bot(TEX("anchor top (accent)"), (.5w,x_ht));
161 endfig;
162 %----------------------------------------------------------
163 beginfig(4);
164 u:=.5cm;
165 noise:=0;
166 h:=6u;
167 x_ht:=4.5u;
168 barheight:=.45h;
169 superness:=.8;
170 w:=20/3*u;
171 leftstemloc:=10/9*u;
172 o:=u/9;
173 px:=2/3*u;
174 py:=.9px;
175 pair randrt;
176 randrt:=(1,0);
177 pickup pencircle xscaled px yscaled py;
178 x1=leftstemloc+noise;
179 x2=leftstemloc+noise;
180 x3=.5w+noise;
181 w-x4=leftstemloc+noise;
182 w-x5=leftstemloc+noise;
183 bot y1=noise-o;
184 y2=barheight+noise;
185 top y3=h+o; %no noise because of Aring
186 y4=barheight+noise;
187 bot y5=noise-o;
188 bot y6=0; %no noise
189 z6=whatever[z4,z5];
190 draw z1--z2
191 & half(z2,z2-z1,z3,randrt,z4,z5-z4)
192 & z4--z5
193 withcolor .8white;
194 draw z2--z4 withcolor .8white;
195 pickup pencircle scaled .5bp
196 draw (0,0) -- (w,0) -- (w,h) -- (0,h) -- cycle;
197 z0=(.5w,h);
198 dotlabel.top(TEX(""), z0);
199 h:=6.5u;
200 w:=28/9*u;
201 pickup pencircle xscaled px yscaled py;
202 lft x11=noise;
203 x12=.5w+noise;
204 rt x13=w+noise;
205 bot y11=.2[x_ht,h]+noise;
206 bot y13=.2[x_ht,h]+noise;
207 top y12=h+o+noise;
208 z10=(.5w,x_ht);
209 draw (z11--z12--z13) shifted (z0-z10) withcolor .8white;
210 pickup pencircle scaled .5bp
211 draw ((0,0) -- (w,0) -- (w,h) -- (0,h) -- cycle) shifted (z0-z10);
212 endfig;
213 %----------------------------------------------------------
214 beginfig(5);
215 u:=.25cm;
216 noise:=0;
217 h:=6u;
218 barheight:=.45h;
219 superness:=.8;
220 w:=20/3*u;
221 leftstemloc:=10/9*u;
222 o:=u/9;
223 px:=2/3*u;
224 py:=.9px;
225 pair randrt;
226 randrt:=(1,0);
227 xgap:=.1h;
228 ygap:=(h/13.5u)*xgap;
229 pickup pencircle xscaled px yscaled py;
230 x1=leftstemloc+noise;
231 x2=leftstemloc+noise;
232 x4=w-leftstemloc+noise;
233 x5=w-leftstemloc+noise;
234 bot y1=noise-o;
235 top y2=h+o+noise;
236 y3=y4+ygap+noise;
237 bot y4=noise-o;
238 top y5=h+o+noise;
239 z3=whatever[z4,z5];
240 draw z1--z2--z3 withcolor .8white;
241 draw z4--z5 withcolor .8white;
242 pickup pencircle scaled .5bp
243 draw (0,0) -- (w,0) -- (w,h) -- (0,h) -- cycle;
244 pickup pencircle xscaled px yscaled py;
245 draw (z1--z2--z3) shifted (w,0) withcolor .8white;
246 draw (z4--z5) shifted (w,0) withcolor .8white;
247 pickup pencircle scaled .5bp;
248 draw ((0,0) -- (w,0) -- (w,h) -- (0,h) -- cycle) shifted (w,0);
249 endfig;
250 %----------------------------------------------------------
251 beginfig(6);
252 u:=.25cm;
253 noise:=0;
254 h:=6u;
255 barheight:=.45h;
256 superness:=.8;
257 w:=20/3*u;
258 leftstemloc:=10/9*u;
259 o:=u/9;
260 px:=2/3*u;
261 py:=.9px;
262 xgap:=.1h;
263 ygap:=(h/13.5u)*xgap;
264 slant:=.25;
265 pair randrt;
266 randrt:=(1,0);
267 pickup pencircle xscaled px yscaled py;
268 x1=leftstemloc+noise;
269 x2=leftstemloc+noise;
270 x4=w-leftstemloc+noise;
271 x5=w-leftstemloc+noise;
272 bot y1=noise-o;
273 top y2=h+o+noise;
274 y3=y4+ygap+noise;
275 bot y4=noise-o;
276 top y5=h+o+noise;
277 z3=whatever[z4,z5];
278 draw (z1--z2--z3) slanted slant withcolor .8white;
279 draw (z4--z5) slanted slant withcolor .8white;
280 draw (z1--z2--z3) shifted (w,0) withcolor .8white;
281 draw (z4--z5) shifted (w,0) withcolor .8white;
282 pickup pencircle scaled .5bp;
283 draw ((0,0) -- (w,0) -- (w,h) -- (0,h) -- cycle) slanted slant;
284 draw ((0,0) -- (w,0) -- (w,h) -- (0,h) -- cycle) shifted (w,0);
285 endfig;
286 %----------------------------------------------------------
287 beginfig(7);
288 u:=.25cm;
289 noise:=0;
290 h:=6u;
291 barheight:=.45h;
292 superness:=.8;
293 w:=20/3*u;
294 leftstemloc:=10/9*u;
295 o:=u/9;
296 px:=2/3*u;
297 py:=.9px;
298 xgap:=.1h;
299 ygap:=(h/13.5u)*xgap;
300 slant:=.25;
301 pair randrt;
302 randrt:=(1,0);
303 pickup pencircle xscaled px yscaled py;
304 x1=leftstemloc+noise;
305 x2=leftstemloc+noise;
306 x4=w-leftstemloc+noise;
307 x5=w-leftstemloc+noise;
308 bot y1=noise-o;
309 top y2=h+o+noise;
310 y3=y4+ygap+noise;
311 bot y4=noise-o;
312 top y5=h+o+noise;
313 z3=whatever[z4,z5];
314 draw (z1--z2--z3) slanted slant shifted (-h*slant,0) withcolor .8white;
315 draw (z4--z5) slanted slant shifted (-h*slant,0) withcolor .8white;
316 draw (z1--z2--z3) shifted (w,0) withcolor .8white;
317 draw (z4--z5) shifted (w,0) withcolor .8white;
318 pickup pencircle scaled .5bp;
319 draw ((0,0) -- (w,0) -- (w,h) -- (0,h) -- cycle) slanted slant shifted (-h*slant,0);
320 draw ((0,0) -- (w,0) -- (w,h) -- (0,h) -- cycle) shifted (w,0);
321 endfig;
322 %----------------------------------------------------------
323 bye