summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/metafun/metafun-environment-samples.tex
blob: 5991a61d5211acd8355313f3abf6b1af4184a8a2 (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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
\startenvironment metafun-environment-sample

\startuseMPgraphic{sample setup}
    numeric Scale ; Scale := 2cm ;
    numeric Size ; Size := 2.5mm/Scale ;
    numeric Pen ; Pen := .25mm/Scale ;
    path Path ;
    pickup pencircle scaled (4Pen) ;
    def InRed    = withcolor .625red    enddef ;
    def InYellow = withcolor .625yellow enddef ;
    def InGray   = withpen pencircle scaled   Pen  withcolor .625white enddef ;
    def InBetween= withpen pencircle scaled (4Pen) withcolor .800white enddef ;
    def InBlack  = withpen pencircle scaled   Pen                      enddef ;
    def InWhite  = withpen pencircle scaled   Pen  withcolor     white enddef ;
    def DrawArrow text t =
        draw      t ; Path := boundingbox currentpicture ;
        drawarrow t ; setbounds currentpicture to Path ;
    enddef ;
    def ColorCircle =
        fill llcircle withcolor .625red    ;
        fill lrcircle withcolor .625green  ;
        fill urcircle withcolor .625blue   ;
        fill ulcircle withcolor .625yellow ;
    enddef ;
    evenly   := dashpattern(on (3mm/Scale) off (3mm/Scale)) ;
    withdots := dashpattern(off (2.5mm/Scale) on 0 off (2.5mm/Scale)) ;
    ahlength := 4mm/Scale ; ahangle := 30 ;
    draw (origin shifted (0,Size)--origin shifted (0,-Size)) ;
    draw (origin shifted (Size,0)--origin shifted (-Size,0)) ;
    picture Origin ; Origin := currentpicture ;
    setbounds Origin to origin--cycle ;
    currentpicture := nullpicture ;
\stopuseMPgraphic

\startuseMPgraphic{sample finish}
    draw boundingbox currentpicture InBlack ;
    draw Origin InGray ;
    currentpicture := currentpicture scaled Scale ;
\stopuseMPgraphic

% fm = metafun  macro
% fv = metafun  variable
% mc = metapost concept
% mm = metapost macro
% mp = metapost primitive
% mv = metapost variable

\starttexdefinition unexpanded DoDoSampleHead#1#2#3
    \setbox\scratchbox\vbox {
        \tabskip\zeropoint
        \tt\tfx
        \halign {
            \strut\hss##\unskip\unskip
            \cr#3\cr#1\cr
        }
    }
    \ht\scratchbox\ht\strutbox
    \dp\scratchbox\dp\strutbox
    \noligature{#2}\black
    \hfill
    \box\scratchbox
    \ignorespaces
\stoptexdefinition

\starttexdefinition unexpanded DoSampleHead #1#2#3
    \processaction
        [#1]
        [fm=>\DoDoSampleHead{metafun      macro}{#2}{#3},
         fv=>\DoDoSampleHead{metafun   variable}{#2}{#3},
         mc=>\DoDoSampleHead{metapost   concept}{#2}{#3},
         mm=>\DoDoSampleHead{metapost     macro}{#2}{#3},
         mp=>\DoDoSampleHead{metapost primitive}{#2}{#3},
         mv=>\DoDoSampleHead{metapost  variable}{#2}{#3}]
\stoptexdefinition

\starttexdefinition unexpanded SampleHead #1#2#3
    \expanded{\extrosubject{\DoSampleHead{#1}{#2}{\detokenize{#3}}}}
\stoptexdefinition

\starttexdefinition unexpanded StartSample
    \doquintuplegroupempty\doStartSample
\stoptexdefinition

\starttexdefinition unexpanded StopSample
    % dummy
\stoptexdefinition

\starttexdefinition unexpanded doStartSample #1#2#3#4#5#6 StopSample
    \bgroup
    \SampleHead{#1}{#2}{#3}
    \startuseMPgraphic{dummy}
        \includeMPgraphic{sample setup}
        #6
        \includeMPgraphic{sample finish}
    \stopuseMPgraphic
    \blank[samepage]
    \startlinecorrection[blank]
        \useMPgraphic{dummy}
    \stoplinecorrection
    \egroup
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleZ #1#2#3
    \bgroup
    \SampleHead{#1}{#2}{}
    \blank[samepage]
    #3
    \par
    \egroup
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleA #1#2#3
    \StartSample{#1}{#2}{#3}
        path p ; p := #3 ; % freeze randomized
        if length(p)>0 :
            DrawArrow  p InRed ;
        fi ;
        drawpoints p InBetween ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleB #1#2#3#4
    \StartSample{#1}{#2}{#4}
        DrawArrow (#3) InRed ;
        DrawArrow (#4) InYellow ;
        drawpoints (#3) InBetween ;
        drawpoints (#4) InBetween ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleC #1#2#3#4
    \StartSample{#1}{#2}{#4}
        path bb ; bb := boundingbox #3 ;
        DrawArrow #3 InRed ;
        draw #4 withpen pencircle scaled .15 InYellow ;
        setbounds currentpicture to bb ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleD #1#2#3#4
    \StartSample{#1}{#2}{#4}
        DrawArrow #3 InRed ;
        setbounds currentpicture to #4 ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleDD #1#2#3#4
    \StartSample{#1}{#2}{#4}
        DrawArrow #3 InRed ;
        DrawArrow #4 InYellow ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleE #1#2#3#4
    \StartSample{#1}{#2}{#4}
        fill fullcircle scaled 1cm InRed ;
        currentpicture := currentpicture #3 ;
        Scale := 1 ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleF #1#2#3#4
    \StartSample{#1}{#2}{#4}
        DrawArrow #3 InRed ;
        drawdot   #4 InYellow ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleG #1#2#3#4
    \StartSample{#1}{#2}{#4}
        draw    #3 InRed ;
        drawdot #4 InYellow ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleH #1#2#3#4#5
    \StartSample{#1}{#2}{#5}
        DrawArrow #3 InRed ;
        DrawArrow #4 InYellow ;
        drawdot   #5 InWhite ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleHH #1#2#3
    \StartSample{#1}{#2}{#3}
        draw #3 InRed ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleI #1#2#3
    \StartSample{#1}{#2}{#3}
        draw fullcircle InRed #3 ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleII #1#2#3
    \StartSample{#1}{#2}{#3}
        draw fullcircle #3 InRed ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleJ #1#2#3
    \StartSample{#1}{withpen #2}{withpen #3 scaled 2mm}
        draw fullcircle xscaled 2 withpen #3 scaled Pen InRed ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleK #1#2#3
    \StartSample{#1}{withpen #2}{withpen #3}
        draw fullcircle xscaled 2 withpen #3 InRed ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleL #1#2#3
    \StartSample{#1}{#2}{#2 #3}
        #2 #3 InRed;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleM #1#2#3
    \StartSample{#1}{#2}{#2 #3}
        fill boundingbox (#3--cycle) InRed ;
        #2 #3 ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleN #1#2#3#4
    \StartSample{#1}{#2}{#3}
        #3 ;
        draw #4 withpen pencircle scaled 25Pen InRed ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleO #1#2#3
    \StartSample{#1}{#2}{#3}
        drawdot origin InRed ;
        #3 scaled (2.5/Scale) InYellow ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleP #1#2#3
    \StartSample{#1}{#2}{#3}
        drawdot origin InRed ;
        #3 scaled (2.5/Scale) InYellow ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleQ #1#2#3
    \StartSample{#1}{#2}{#3}
        #2 #3 withpen pencircle scaled 25Pen InRed ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleQQ #1#2#3
    \StartSample{#1}{#2}{#3}
        #3 scaled (2.5/Scale) withpen pencircle scaled Pen InYellow ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleQQQ #1#2#3
    \StartSample{#1}{#2}{#3}
        #3 scaled (2.5/Scale) withpen pencircle scaled Pen ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleR #1#2#3
    \StartSample{#1}{#2}{#3}
        ColorCircle ;
        addto currentpicture also (#3) shifted (bbwidth(currentpicture)+.1,0) ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleS #1#2#3
    \StartSample{#1}{#2}{#3}
        Pen := Pen * Scale ; Scale := 1 ; #3 ;%
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleT #1#2#3#4
    \StartSample{#1}{#2}{#3}
        #4 ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleU #1#2#3
    \StartSample{#1}{#2}{#3}
        Scale := Scale / 5 ;
        #3 ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleUU #1#2#3
    \StartSample{#1}{#2}{#3}
        Scale := Scale / 10 ;
        #3 ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleV #1#2#3#4
    \StartSample{#1}{#2}{#3}
        Scale := Scale / 5 ;
        Pen := Pen * 20 ;
        #4 ;
        Pen := Pen / 20 ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleW #1#2#3#4
    \StartSample{#1}{#2}{#3}
        Scale := 1 ;
        #4 ;
    \StopSample
\stoptexdefinition

\starttexdefinition unexpanded ShowSampleX #1#2#3
    \StartSample{#1}{#2}{#3}
        #3 InRed ;
    \StopSample
\stoptexdefinition

\stopenvironment