1
2
3\startenvironment metafunenvironmentsample
4
5\startuseMPgraphic{sample setup}
6 numeric Scale ; Scale := 2cm ;
7 numeric Size ; Size := 2.5mmScale ;
8 numeric Pen ; Pen := .25mmScale ;
9 path Path ;
10 pickup pencircle scaled (4Pen) ;
11 def InRed = withcolor .625red enddef ;
12 def InYellow = withcolor .625yellow enddef ;
13 def InGray = withpen pencircle scaled Pen withcolor .625white enddef ;
14 def InBetween= withpen pencircle scaled (4Pen) withcolor .800white enddef ;
15 def InBlack = withpen pencircle scaled Pen enddef ;
16 def InWhite = withpen pencircle scaled Pen withcolor white enddef ;
17 def DrawArrow text t =
18 draw t ; Path := boundingbox currentpicture ;
19 drawarrow t ; setbounds currentpicture to Path ;
20 enddef ;
21 def ColorCircle =
22 fill llcircle withcolor .625red ;
23 fill lrcircle withcolor .625green ;
24 fill urcircle withcolor .625blue ;
25 fill ulcircle withcolor .625yellow ;
26 enddef ;
27 evenly := dashpattern(on (3mmScale) off (3mmScale)) ;
28 withdots := dashpattern(off (2.5mmScale) on 0 off (2.5mmScale)) ;
29 ahlength := 4mmScale ; ahangle := 30 ;
30 draw (origin shifted (0,Size)origin shifted (0,Size)) ;
31 draw (origin shifted (Size,0)origin shifted (Size,0)) ;
32 picture Origin ; Origin := currentpicture ;
33 setbounds Origin to origincycle ;
34 currentpicture := nullpicture ;
35\stopuseMPgraphic
36
37\startuseMPgraphic{sample finish}
38 draw boundingbox currentpicture InBlack ;
39 draw Origin InGray ;
40 currentpicture := currentpicture scaled Scale ;
41\stopuseMPgraphic
42
43
44
45
46
47
48
49
50\starttexdefinition unexpanded DoDoSampleHead#1#2#3
51 \setbox\scratchbox\vbox {
52 \tabskip\zeropoint
53 \tt\tfx
54 \halign {
55 \strut\hss##\unskip\unskip
56 \cr#3\cr#1\cr
57 }
58 }
59 \ht\scratchbox\ht\strutbox
60 \dp\scratchbox\dp\strutbox
61 \noligature{#2}\black
62 \hfill
63 \box\scratchbox
64 \ignorespaces
65\stoptexdefinition
66
67\starttexdefinition unexpanded DoSampleHead #1#2#3
68 \processaction
69 [#1]
70 [fm=>\DoDoSampleHead{metafun macro}{#2}{#3},
71 fv=>\DoDoSampleHead{metafun variable}{#2}{#3},
72 mc=>\DoDoSampleHead{metapost concept}{#2}{#3},
73 mm=>\DoDoSampleHead{metapost macro}{#2}{#3},
74 mp=>\DoDoSampleHead{metapost primitive}{#2}{#3},
75 mv=>\DoDoSampleHead{metapost variable}{#2}{#3}]
76\stoptexdefinition
77
78\starttexdefinition unexpanded SampleHead #1#2#3
79 \expanded{\extrosubject{\DoSampleHead{#1}{#2}{\detokenize{#3}}}}
80\stoptexdefinition
81
82\starttexdefinition unexpanded StartSample
83 \doquintuplegroupempty\doStartSample
84\stoptexdefinition
85
86\starttexdefinition unexpanded StopSample
87
88\stoptexdefinition
89
90\starttexdefinition unexpanded doStartSample #1#2#3#4#5#6 StopSample
91 \bgroup
92 \SampleHead{#1}{#2}{#3}
93 \startuseMPgraphic{dummy}
94 \includeMPgraphic{sample setup}
95 #6
96 \includeMPgraphic{sample finish}
97 \stopuseMPgraphic
98 \blank[samepage]
99 \startlinecorrection[blank]
100 \useMPgraphic{dummy}
101 \stoplinecorrection
102 \egroup
103\stoptexdefinition
104
105\starttexdefinition unexpanded ShowSampleZ #1#2#3
106 \bgroup
107 \SampleHead{#1}{#2}{}
108 \blank[samepage]
109 #3
110 \par
111 \egroup
112\stoptexdefinition
113
114\starttexdefinition unexpanded ShowSampleA #1#2#3
115 \StartSample{#1}{#2}{#3}
116 path p ; p := #3 ;
117 if length(p)>0 :
118 DrawArrow p InRed ;
119 fi ;
120 drawpoints p InBetween ;
121 \StopSample
122\stoptexdefinition
123
124\starttexdefinition unexpanded ShowSampleB #1#2#3#4
125 \StartSample{#1}{#2}{#4}
126 DrawArrow (#3) InRed ;
127 DrawArrow (#4) InYellow ;
128 drawpoints (#3) InBetween ;
129 drawpoints (#4) InBetween ;
130 \StopSample
131\stoptexdefinition
132
133\starttexdefinition unexpanded ShowSampleC #1#2#3#4
134 \StartSample{#1}{#2}{#4}
135 path bb ; bb := boundingbox #3 ;
136 DrawArrow #3 InRed ;
137 draw #4 withpen pencircle scaled .15 InYellow ;
138 setbounds currentpicture to bb ;
139 \StopSample
140\stoptexdefinition
141
142\starttexdefinition unexpanded ShowSampleD #1#2#3#4
143 \StartSample{#1}{#2}{#4}
144 DrawArrow #3 InRed ;
145 setbounds currentpicture to #4 ;
146 \StopSample
147\stoptexdefinition
148
149\starttexdefinition unexpanded ShowSampleDD #1#2#3#4
150 \StartSample{#1}{#2}{#4}
151 DrawArrow #3 InRed ;
152 DrawArrow #4 InYellow ;
153 \StopSample
154\stoptexdefinition
155
156\starttexdefinition unexpanded ShowSampleE #1#2#3#4
157 \StartSample{#1}{#2}{#4}
158 fill fullcircle scaled 1cm InRed ;
159 currentpicture := currentpicture #3 ;
160 Scale := 1 ;
161 \StopSample
162\stoptexdefinition
163
164\starttexdefinition unexpanded ShowSampleF #1#2#3#4
165 \StartSample{#1}{#2}{#4}
166 DrawArrow #3 InRed ;
167 drawdot #4 InYellow ;
168 \StopSample
169\stoptexdefinition
170
171\starttexdefinition unexpanded ShowSampleG #1#2#3#4
172 \StartSample{#1}{#2}{#4}
173 draw #3 InRed ;
174 drawdot #4 InYellow ;
175 \StopSample
176\stoptexdefinition
177
178\starttexdefinition unexpanded ShowSampleH #1#2#3#4#5
179 \StartSample{#1}{#2}{#5}
180 DrawArrow #3 InRed ;
181 DrawArrow #4 InYellow ;
182 drawdot #5 InWhite ;
183 \StopSample
184\stoptexdefinition
185
186\starttexdefinition unexpanded ShowSampleHH #1#2#3
187 \StartSample{#1}{#2}{#3}
188 draw #3 InRed ;
189 \StopSample
190\stoptexdefinition
191
192\starttexdefinition unexpanded ShowSampleI #1#2#3
193 \StartSample{#1}{#2}{#3}
194 draw fullcircle InRed #3 ;
195 \StopSample
196\stoptexdefinition
197
198\starttexdefinition unexpanded ShowSampleII #1#2#3
199 \StartSample{#1}{#2}{#3}
200 draw fullcircle #3 InRed ;
201 \StopSample
202\stoptexdefinition
203
204\starttexdefinition unexpanded ShowSampleJ #1#2#3
205 \StartSample{#1}{withpen #2}{withpen #3 scaled 2mm}
206 draw fullcircle xscaled 2 withpen #3 scaled Pen InRed ;
207 \StopSample
208\stoptexdefinition
209
210\starttexdefinition unexpanded ShowSampleK #1#2#3
211 \StartSample{#1}{withpen #2}{withpen #3}
212 draw fullcircle xscaled 2 withpen #3 InRed ;
213 \StopSample
214\stoptexdefinition
215
216\starttexdefinition unexpanded ShowSampleL #1#2#3
217 \StartSample{#1}{#2}{#2 #3}
218 #2 #3 InRed;
219 \StopSample
220\stoptexdefinition
221
222\starttexdefinition unexpanded ShowSampleM #1#2#3
223 \StartSample{#1}{#2}{#2 #3}
224 fill boundingbox (#3cycle) InRed ;
225 #2 #3 ;
226 \StopSample
227\stoptexdefinition
228
229\starttexdefinition unexpanded ShowSampleN #1#2#3#4
230 \StartSample{#1}{#2}{#3}
231 #3 ;
232 draw #4 withpen pencircle scaled 25Pen InRed ;
233 \StopSample
234\stoptexdefinition
235
236\starttexdefinition unexpanded ShowSampleO #1#2#3
237 \StartSample{#1}{#2}{#3}
238 drawdot origin InRed ;
239 #3 scaled (2.5Scale) InYellow ;
240 \StopSample
241\stoptexdefinition
242
243\starttexdefinition unexpanded ShowSampleP #1#2#3
244 \StartSample{#1}{#2}{#3}
245 drawdot origin InRed ;
246 #3 scaled (2.5Scale) InYellow ;
247 \StopSample
248\stoptexdefinition
249
250\starttexdefinition unexpanded ShowSampleQ #1#2#3
251 \StartSample{#1}{#2}{#3}
252 #2 #3 withpen pencircle scaled 25Pen InRed ;
253 \StopSample
254\stoptexdefinition
255
256\starttexdefinition unexpanded ShowSampleQQ #1#2#3
257 \StartSample{#1}{#2}{#3}
258 #3 scaled (2.5Scale) withpen pencircle scaled Pen InYellow ;
259 \StopSample
260\stoptexdefinition
261
262\starttexdefinition unexpanded ShowSampleQQQ #1#2#3
263 \StartSample{#1}{#2}{#3}
264 #3 scaled (2.5Scale) withpen pencircle scaled Pen ;
265 \StopSample
266\stoptexdefinition
267
268\starttexdefinition unexpanded ShowSampleR #1#2#3
269 \StartSample{#1}{#2}{#3}
270 ColorCircle ;
271 addto currentpicture also (#3) shifted (bbwidth(currentpicture).1,0) ;
272 \StopSample
273\stoptexdefinition
274
275\starttexdefinition unexpanded ShowSampleS #1#2#3
276 \StartSample{#1}{#2}{#3}
277 Pen := Pen * Scale ; Scale := 1 ; #3 ;
278 \StopSample
279\stoptexdefinition
280
281\starttexdefinition unexpanded ShowSampleT #1#2#3#4
282 \StartSample{#1}{#2}{#3}
283 #4 ;
284 \StopSample
285\stoptexdefinition
286
287\starttexdefinition unexpanded ShowSampleU #1#2#3
288 \StartSample{#1}{#2}{#3}
289 Scale := Scale 5 ;
290 #3 ;
291 \StopSample
292\stoptexdefinition
293
294\starttexdefinition unexpanded ShowSampleUU #1#2#3
295 \StartSample{#1}{#2}{#3}
296 Scale := Scale 10 ;
297 #3 ;
298 \StopSample
299\stoptexdefinition
300
301\starttexdefinition unexpanded ShowSampleV #1#2#3#4
302 \StartSample{#1}{#2}{#3}
303 Scale := Scale 5 ;
304 Pen := Pen * 20 ;
305 #4 ;
306 Pen := Pen 20 ;
307 \StopSample
308\stoptexdefinition
309
310\starttexdefinition unexpanded ShowSampleW #1#2#3#4
311 \StartSample{#1}{#2}{#3}
312 Scale := 1 ;
313 #4 ;
314 \StopSample
315\stoptexdefinition
316
317\starttexdefinition unexpanded ShowSampleX #1#2#3
318 \StartSample{#1}{#2}{#3}
319 #3 InRed ;
320 \StopSample
321\stoptexdefinition
322
323\stopenvironment
324 |