1
2
3\startenvironment metafunenvironment
4
5\environment metafunenvironmentlayout
6
7\usemodule[abr01,syntax]
8
9\startuseMPgraphic{cover page}
10
11 numeric w ; w := PaperWidth eps ;
12 numeric h ; h := PaperHeighteps ;
13
14 for i=0cm step 1cm until w :
15 for j=0cm step 1cm until h :
16 fill unitsquare scaled 1cm shifted (i,j) withcolor (.6uniformdeviate.35)white ;
17 endfor ;
18 endfor ;
19
20
21
22 for i=0cm step 1cm until w+.5cm :
23 draw (i,0) -- (i,h) withpen pensquare scaled .5mm withcolor .625yellow ;
24 endfor ;
25
26 for i=0cm step 1cm until h+.5cm :
27 draw (0,i) -- (w,i) withpen pensquare scaled .5mm withcolor .625yellow ;
28 endfor ;
29
30\stopuseMPgraphic
31
32\startuseMPgraphic{title page}
33
34 StartPage ;
35
36 \includeMPgraphic{cover page}
37
38 picture p ; p := image (draw rawtextext("\darkred\definedfont[Sans]metafun" )) ;
39 picture q ; q := image (draw rawtextext("\darkred\definedfont[Sans]Hans Hagen")) ;
40
41 picture r ; r := image (draw rawtextext("\darkred\definedfont[Sans]context mkiv")) ;
42
43 p := p xsized(PaperHeight 2cm) ;
44 q := q xsized(PaperWidth 8cm) ;
45 r := r xsized(6cm) ;
46
47 p := p rotated 90 ;
48 r := r rotated 90 ;
49
50 draw p shifted (urcorner Page urcorner p (1cm,1cm) (-1mm,0) ) ;
51 draw q shifted (1cm, 1cm) ;
52 draw r shifted (urcorner Page urcorner r (5cm,2cm) ) ;
53
54 StopPage ;
55
56 setbounds currentpicture to Page ;
57
58\stopuseMPgraphic
59
60\startuseMPgraphic{back page}
61
62 \includeMPgraphic{cover page}
63
64\stopuseMPgraphic
65
66\startuseMPgraphic{small grid}
67
68 numeric w ; w := \overlaywidth ;
69 numeric h ; h := \overlayheight ;
70 numeric d ; d := .25cm ;
71
72 drawoptions(withcolor (.6uniformdeviate.35)white) ;
73
74 for i=0cm step d until w :
75 for j=0cm step d until h :
76 fill unitsquare scaled d shifted (i,j) ;
77 endfor ;
78 endfor ;
79
80 drawoptions(withpen pencircle scaled .125mm withcolor .625yellow) ;
81
82 for i=0 step d until wd : draw (i,0) -- (i,h) ; endfor ;
83 for i=0 step d until hd : draw (0,i) -- (w,i) ; endfor ;
84
85\stopuseMPgraphic
86
87\defineoverlay[title page][\useMPgraphic{title page}]
88
89\startnotmode[proof]
90 \defineoverlay[back page][\useMPgraphic{back page}]
91 \defineoverlay[small grid][\useMPgraphic{small grid}]
92\stopnotmode
93
94
95
96\starttexdefinition unexpanded OnGrid#1
97 \hbox to \hsize \bgroup
98 \ifodd\realpageno
99 \hss
100 \fi
101 \setbox\scratchbox=\hbox {
102 \color[darkred]{#1}
103 }
104 \scratchoffset.25cm
105 \scratchwidth\wd\scratchbox
106 \ifdim\scratchwidth>\zeropoint
107 \advance \scratchwidth by .5\scratchoffset
108 \divide \scratchwidth by \scratchoffset
109 \multiply\scratchwidth by \scratchoffset
110 \advance \scratchwidth by 2\scratchoffset
111 \else
112 \scratchwidth8\scratchoffset
113 \fi
114 \dp\scratchbox \scratchoffset
115 \ht\scratchbox 2\scratchoffset
116 \framed [
117 background=small grid,
118 frame=off,
119 offset=overlay
120 ] {
121 \hbox to \scratchwidth {
122 \hss
123 \box\scratchbox
124 \hss
125 }
126 }
127 \unless \ifodd\realpageno
128 \hss
129 \fi
130 \egroup
131\stoptexdefinition
132
133\setupfootertexts
134 [margin]
135 []
136 [\OnGrid{\doifelsetext{\getmarking[chapter]}{\getmarking[chapter]}{\getmarking[title]}}]
137
138\startuseMPgraphic{circled}
139 pickup pencircle scaled 1mm ;
140 drawoptions(withcolor (.6uniformdeviate.35)white) ;
141 fill fullcircle xscaled 1.5cm yscaled 1cm ;
142 drawoptions(withcolor .625yellow) ;
143 draw fullcircle xscaled 1.5cm yscaled 1cm ;
144\stopuseMPgraphic
145
146\startnotmode[proof]
147 \defineoverlay[circled][\useMPgraphic{circled}]
148\stopnotmode
149
150\starttexdefinition unexpanded Circled #1
151 \framed [
152 background=circled,
153 frame=off,
154 offset=overlay
155 ] {
156 \color[darkred]{#1}
157 }
158\stoptexdefinition
159
160\setuppagenumbering
161 [location=]
162
163\setupheadertexts
164 [margin]
165 [][\hbox to \hsize{\hss\Circled\pagenumber\hss}]
166
167\setupheader
168 [style=bold]
169
170\setupfooter
171 [style=bold]
172
173\startuniqueMPgraphic{titled}
174 path p ; p := unitsquare xscaled OverlayWidth yscaled OverlayHeight ;
175 pickup pencircle scaled 1mm ;
176 drawoptions(withcolor .625yellow) ;
177 draw llcorner p -- lrcorner p ;
178 setbounds currentpicture to p ;
179\stopuniqueMPgraphic
180
181\defineoverlay[titled][\uniqueMPgraphic{titled}]
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\starttexdefinition unexpanded ChapterCommand #1#2
215 \ifconditional\headshownumber
216 \hskip\leftmargintotal\relax
217 \framed [
218 background=titled,
219 frame=off,
220 offset=0pt
221 ] {
222 \hbox to \leftmarginwidth {
223 #1
224 \hss
225 }
226 \hskip\leftmargindistance\relax
227 #2
228 }
229 \else
230 \framed [
231 background=titled,
232 frame=off,
233 offset=0pt
234 ] {
235 #2
236 }
237 \fi
238\stoptexdefinition
239
240\starttexdefinition unexpanded TitleCommand #1#2
241 \framed [
242 background=titled,
243 frame=off,
244 offset=0pt
245 ] {
246 #2
247 }
248\stoptexdefinition
249
250\starttexdefinition unexpanded IntroTitleCommand #1#2
251 \framed [
252 background=titled,
253 frame=off,
254 offset=0pt,
255 width=\textwidth
256 ] {
257 \hfill
258 #2
259 }
260\stoptexdefinition
261
262\starttexdefinition unexpanded ExtroTitleCommand #1#2
263 \framed [
264 background=titled,
265 frame=off,
266 offset=0pt,
267 width=\textwidth
268 ] {
269 \hss
270 #2
271 \hss
272 }
273\stoptexdefinition
274
275\setuphead
276 [chapter,section,subsection,subsubsection]
277 [color=darkred]
278
279\setuphead
280 [chapter]
281 [style=\bfc]
282
283\setuphead
284 [section]
285 [style=\bfa]
286
287\setuphead
288 [subsection]
289 [style=\bf]
290
291\setuphead
292 [subsubsection]
293 [style=\bf]
294
295\setuphead
296 [chapter,section,subsection,subsubsection]
297 [command=\ChapterCommand]
298
299\setuphead
300 [title,subject,subsubject,subsubsubject]
301 [command=\TitleCommand]
302
303
304\definehead [introsubject] [subsubject]
305\definehead [extrosubject] [subsubject]
306
307\setuphead [introsubject] [command=\IntroTitleCommand]
308\setuphead [extrosubject] [command=\ExtroTitleCommand]
309
310\setuphead
311 [subsection,subsubject]
312 [before=\blank,
313 after=\blank]
314
315
316
317\usemodule[chart]
318
319\setupFLOWcharts
320 [offset=0pt,
321 width=6\bodyfontsize,
322 height=3\bodyfontsize,
323 dx=\bodyfontsize,
324 dy=\bodyfontsize]
325
326\setupFLOWshapes
327 [framecolor=darkred]
328
329\setupFLOWlines
330 [color=darkyellow]
331
332
333
334\setupbackgrounds
335 [page]
336 [background={backgraphics,foreground,foregraphics}]
337
338\defineoverlay [backgraphics] [\positionoverlay{backgraphics}]
339\defineoverlay [foregraphics] [\positionoverlay{foregraphics}]
340
341\startbuffer[shapea]
342\startuniqueMPgraphic{meta:hash}{linewidth,linecolor,angle,gap}
343 loadmodule("back") ;
344 some_hash ( OverlayWidth, OverlayHeight ,
345 \MPvar{linewidth}, \MPvar{linecolor} ,
346 \MPvar{angle}, \MPvar{gap} ) ;
347\stopuniqueMPgraphic
348\stopbuffer
349
350\startbuffer[shapeb]
351\setupMPvariables
352 [meta:hash]
353 [gap=.25\bodyfontsize,
354 angle=45,
355 linewidth=\overlaylinewidth,
356 linecolor=\overlaylinecolor]
357\stopbuffer
358
359\startbuffer[shapec]
360\def\metahashoverlay#1{\uniqueMPgraphic{meta:hash}{angle=#1}}
361
362\defineoverlay[meta:hash:right] [\metahashoverlay{ 45}]
363\defineoverlay[meta:hash:left] [\metahashoverlay{ 45}]
364\defineoverlay[meta:hash:horizontal][\metahashoverlay{180}]
365\defineoverlay[meta:hash:vertical] [\metahashoverlay{ 90}]
366\stopbuffer
367
368\startbuffer[symba]
369\startuniqueMPgraphic{meta:button}{type,size,linecolor,fillcolor}
370 loadmodule("butt") ;
371 some_button ( \MPvar{type},
372 \MPvar{size},
373 \MPvar{linecolor},
374 \MPvar{fillcolor} ) ;
375\stopuniqueMPgraphic
376\stopbuffer
377
378\startbuffer[symbb]
379\setupMPvariables
380 [meta:button]
381 [type=1,
382 size=2\bodyfontsize,
383 fillcolor=gray,
384 linecolor=darkred]
385\stopbuffer
386
387\startbuffer[symbc]
388\def\metabuttonsymbol#1{\uniqueMPgraphic{meta:button}{type=#1}}
389
390\definesymbol[menu:left] [\metabuttonsymbol{101}]
391\definesymbol[menu:right] [\metabuttonsymbol{102}]
392\definesymbol[menu:list] [\metabuttonsymbol{103}]
393\definesymbol[menu:index] [\metabuttonsymbol{104}]
394\definesymbol[menu:person][\metabuttonsymbol{105}]
395\definesymbol[menu:stop] [\metabuttonsymbol{106}]
396\definesymbol[menu:info] [\metabuttonsymbol{107}]
397\definesymbol[menu:down] [\metabuttonsymbol{108}]
398\definesymbol[menu:up] [\metabuttonsymbol{109}]
399\definesymbol[menu:print] [\metabuttonsymbol{110}]
400\stopbuffer
401
402\hyphenation{toolkit}
403
404\startbuffer[pagetext]
405\subject{Edward R. Tufte} \input tufte \par
406\subject{Donald E. Knuth} \input knuth \par
407\subject{Douglas R. Hostadter} \input douglas \page
408\stopbuffer
409
410\startbuffer[back0]
411\defineoverlay[page][\useMPgraphic{page}]
412\setupbackgrounds[page][background=page]
413\stopbuffer
414
415\startbuffer[back1]
416\startuseMPgraphic{page}
417 StartPage ;
418 path Main ;
419 if OnRightPage :
420 Main := lrcorner Field[OuterMargin][Text] --
421 llcorner Field[Text] [Text] --
422 ulcorner Field[Text] [Text] --
423 urcorner Field[OuterMargin][Text] -- cycle ;
424 else :
425 Main := llcorner Field[OuterMargin][Text] --
426 lrcorner Field[Text] [Text] --
427 urcorner Field[Text] [Text] --
428 ulcorner Field[OuterMargin][Text] -- cycle ;
429 fi ;
430 Main := Main enlarged 6pt ;
431 pickup pencircle scaled 2pt ;
432 fill Page withcolor .625white ;
433 fill Main withcolor .850white ;
434 draw Main withcolor .625red ;
435 StopPage ;
436\stopuseMPgraphic
437\stopbuffer
438
439\startbuffer[back2]
440\startuseMPgraphic{page}
441 StartPage ;
442 pickup pencircle scaled 2pt ;
443 fill Page withcolor .625white ;
444 fill Field[OuterMargin][Text] withcolor .850white ;
445 fill Field[Text] [Text] withcolor .850white ;
446 draw Field[OuterMargin][Text] withcolor .625red ;
447 draw Field[Text] [Text] withcolor .625red ;
448 StopPage ;
449\stopuseMPgraphic
450\stopbuffer
451
452\startbuffer[back3]
453\startuseMPgraphic{page}
454 StartPage ;
455 pickup pencircle scaled 2pt ;
456 fill Page withcolor .625white ;
457 fill Field[Text][Text] enlarged .5cm withcolor .850white ;
458 draw Field[Text][Text] enlarged .5cm withcolor .625red ;
459 StopPage ;
460\stopuseMPgraphic
461\stopbuffer
462
463\startbuffer[back4]
464\startuseMPgraphic{page}
465 StartPage ;
466 def somewhere =
467 (uniformdeviate 1cm,uniformdeviate 1cm)
468 enddef ;
469 path Main ;
470 Main := Field[Text][Text] lrmoved somewhere --
471 Field[Text][Text] llmoved somewhere --
472 Field[Text][Text] ulmoved somewhere --
473 Field[Text][Text] urmoved somewhere -- cycle ;
474 pickup pencircle scaled 2pt ;
475 fill Page withcolor .625white ;
476 fill Main withcolor .850white ;
477 draw Main withcolor .625red ;
478 StopPage ;
479\stopuseMPgraphic
480\stopbuffer
481
482\startbuffer[back4x]
483\startuseMPgraphic{page}
484 StartPage ;
485 path Main ; Main := Field[Text][Text] randomized 1cm ;
486 pickup pencircle scaled 2pt ;
487 fill Page withcolor .625white ;
488 fill Main withcolor .850white ;
489 draw Main withcolor .625red ;
490 StopPage ;
491\stopuseMPgraphic
492\stopbuffer
493
494\startbuffer[back5]
495\startuseMPgraphic{page}
496 StartPage
497 for i=Top,Header,Text,Footer,Bottom :
498 for j=LeftEdge,LeftMargin,Text,RightMargin,RightEdge :
499 draw Field[i][j] withpen pencircle scaled 2pt withcolor .625red ;
500 endfor ;
501 endfor ;
502 StopPage
503\stopuseMPgraphic
504\stopbuffer
505
506\starttexdefinition unexpanded Literature #1#2#3
507 \blank
508 \noindentation
509 #1
510 \space
511 \begingroup
512 \bf
513 #2
514 \endgroup
515 \space
516 #3
517 \blank
518\stoptexdefinition
519
520\environment metafunenvironmentsamples
521
522\startbuffer[handwrit]
523
524\usetypescript[serif][chorus]
525
526\definefont[SomeHandwriting][TeXGyreChorusMediumItalic*default at 12pt]
527
528\start \SomeHandwriting\setstrut
529
530\startMPpage
531 StartPage ;
532 numeric l, n ; path p ;
533 l := 1.5LineHeight ;
534 n := 0 ;
535 p := origin shifted (l,0) -- origin shifted (PaperWidthl,0) ;
536 for i=PaperHeightl step l until l :
537 n := n 1 ;
538 fill p shifted (0,iStrutHeight) --
539 reverse p shifted (0,iStrutDepth ) -- cycle
540 withcolor .85white ;
541 draw p shifted (0,i)
542 withpen pencircle scaled .25pt
543 withcolor .5white ;
544 draw p shifted (0,iExHeight)
545 withpen pencircle scaled .25pt
546 withcolor .5white ;
547 draw textext.origin("\strut How are those penalty lines called
548 in english? I may not steal candies ..." & decimal n)
549 shifted (l,i)
550 shifted (0,StrutDepth) ;
551 endfor ;
552 StopPage ;
553\stopMPpage
554\stop
555\stopbuffer
556
557\startbuffer[gridpage]
558\startMPpage
559 StartPage ;
560 width := PaperWidth ; height := PaperHeight ; unit := cm ;
561 drawoptions(withpen pencircle scaled .2pt withcolor .8white) ;
562 draw vlingrid(0, width unit, 110, width, height) ;
563 draw hlingrid(0, heightunit, 110, height, width ) ;
564 drawoptions(withpen pencircle scaled .5pt withcolor .4white) ;
565 draw vlingrid(0, width unit, 1, width, height) ;
566 draw hlingrid(0, heightunit, 1, height, width ) ;
567 StopPage ;
568\stopMPpage
569\stopbuffer
570
571
572
573\startmode[screen]
574
575\startbuffer[wipe]
576picture savedpicture ;
577savedpicture := currentpicture ;
578currentpicture := nullpicture ;
579draw savedpicture withcolor black ;
580draw savedpicture ;
581\stopbuffer
582
583\stopmode
584
585\startnotmode[screen]
586
587\startbuffer[wipe]
588
589\stopbuffer
590
591\stopnotmode
592
593\startbuffer[backtext]
594
595 This document introduces you in the world of the graphic programming language
596 \MetaPost. Not only the language itself is covered in detail, but also the way to
597 interface with the typographic language \TeX. We also present the collection of
598 \MetaPost\ extensions that come with the \ConTeXt\ typesetting system. This
599 collection goes under the name \MetaFun.
600
601 \blank
602
603 All aspects of the \MetaPost\ language are covered. The first chapters focus on
604 the language itself, later chapters cover aspects like color, graphic
605 inclusions, adding labels, and stepwise constructing graphics. We finish with a
606 graphical overview of commands.
607
608\stopbuffer
609
610\startbuffer[backbanner]
611
612 \WidthSpanningText
613 {PRAGMA Advanced Document Engineering, Hasselt NL, \currentdate[year]}
614 {\hsize}
615 {RegularBold}
616
617\stopbuffer
618
619\stopenvironment
620 |