MetaFun - Pragma ADE
MetaFun - Pragma ADE MetaFun - Pragma ADE
4 Content 9 Functions . . . . . . . . . . . . . . . . . . . . . 211 9.1 Overview . . . . . . . . . . . . . . . . . . . 211 9.2 Grids . . . . . . . . . . . . . . . . . . . . . . . 213 9.3 Drawing functions . . . . . . . . . . . 216 10 Typesetting in METAPOST . . . . . . 225 10.1 The process . . . . . . . . . . . . . . . . . 225 10.2 Environments . . . . . . . . . . . . . . . 225 10.3 Labels . . . . . . . . . . . . . . . . . . . . . . 226 10.4 TEX text . . . . . . . . . . . . . . . . . . . . 227 10.5 Talking to TEX . . . . . . . . . . . . . . . 238 10.6 Libraries . . . . . . . . . . . . . . . . . . . . 247 11 Debugging . . . . . . . . . . . . . . . . . . . . 255 12 Defining styles . . . . . . . . . . . . . . . . 261 12.1 Adaptive buttons . . . . . . . . . . . . 261 13 A few applications . . . . . . . . . . . . . 271 13.1 Simple drawings . . . . . . . . . . . . . 271 13.2 Free labels . . . . . . . . . . . . . . . . . . 274 13.3 Marking angles . . . . . . . . . . . . . . 279 13.4 Color circles . . . . . . . . . . . . . . . . 285 13.5 Fool yourself . . . . . . . . . . . . . . . . 292 13.6 Growing graphics . . . . . . . . . . . . 296 13.7 Simple Logos . . . . . . . . . . . . . . . . 304 13.8 Music sheets . . . . . . . . . . . . . . . . 309 13.9 The euro symbol . . . . . . . . . . . . . 310 13.10 Killing time . . . . . . . . . . . . . . . . . 314 14 METAFUN macros . . . . . . . . . . . . . 319 A METAPOST syntax . . . . . . . . . . . . . 321 A.1 Syntax diagrams . . . . . . . . . . . . . 321 A.2 Left overs . . . . . . . . . . . . . . . . . . . 331 B This document . . . . . . . . . . . . . . . . 333 C Reference . . . . . . . . . . . . . . . . . . . . . 335 C.1 Paths . . . . . . . . . . . . . . . . . . . . . . . 335 C.2 Transformations . . . . . . . . . . . . . 346 C.3 Points . . . . . . . . . . . . . . . . . . . . . . 357 C.4 Attributes . . . . . . . . . . . . . . . . . . . 359 C.5 Text . . . . . . . . . . . . . . . . . . . . . . . . 364 C.6 Graphics . . . . . . . . . . . . . . . . . . . . 366 D Literature . . . . . . . . . . . . . . . . . . . . . 367 D.1 METAFONT and METAPOST . . 367 D.2 TEX . . . . . . . . . . . . . . . . . . . . . . . . 367 D.3 CONTEXT . . . . . . . . . . . . . . . . . . 367 D.4 Tools . . . . . . . . . . . . . . . . . . . . . . . 368 D.5 Distributions . . . . . . . . . . . . . . . . 368 Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369
1 Conventions When reading this manual, you may be tempted to test the examples shown. This can be done in several ways. You can make a file and process that file by METAPOST. Such a file looks like: beginfig(1) ; fill fullcircle scaled 5cm withcolor red ; % a graphic endfig ; end . Don't forget the semi--colons that end the statements. If the file is saved as yourfile.mp, then the file is processed by: mpost --mem=metafun.mem yourfile The results are available in yourfile.1 and can be viewed with GHOSTSCRIPT. You don't need to close the file so reprocessing is very convenient. Alternatively you can use CONTEXT. In that case, a simple file looks like: \starttext \startMPpage fill fullcircle scaled 5cm withcolor red ; \stopMPpage \startMPpage fill unitsquare scaled 5cm withcolor red ; \stopMPpage \stoptext If the file is saved as yourfile.tex, then you can produce a PDF file with: 1 context yourfile This will use LUATEX and CONTEXT MKIV to produce a file with two pages using the built in METAPOST library with METAFUN. When you use this route you will automatically get the integrated text support shown in this manual, including OPENTYPE support. If one page is enough, you can also say: \startMPpage fill fullcircle scaled 5cm withcolor red ; \stopMPpage So when you have a running CONTEXT on your system you don't need to bother about installing METAPOST and running METAFUN. We will use lots of color. Don't worry if your red is not our red, or your yellow does not match ours. We've made color definitions to match the overall design of this document, but you should feel free to use any color of choice in the upcoming examples. We assume that you are using CONTEXT MKIV, otherwise you need to run texexec with the --mptex flag. 5 Conventions
- Page 1: Hans Hagen metafun context mkiv
- Page 5 and 6: Introduction This document is about
- Page 7: Content Conventions . . . . . . . .
- Page 11 and 12: 1 Welcome to MetaPost 1.1 Paths 2 I
- Page 13 and 14: The open path is defined as: (1cm,1
- Page 15 and 16: 1.2 Transformations We can store a
- Page 17 and 18: (x,y) zscaled (u,v) (xu − yv,xv +
- Page 19 and 20: z0 = (0.5cm,1.5cm) ; z1 = (2.5cm,2.
- Page 21 and 22: 4 0 1 3 2 "z0..z1..z2..z3..z0" Only
- Page 23 and 24: 0 1 3 2 "z0..z1..z2--z3" Watch how
- Page 25 and 26: 0 1 0 2 2 1 "(z0..z1..z2..z3) cutaf
- Page 27 and 28: 2 0 1 Using ( ) is not mandatory bu
- Page 29 and 30: 0 4 1 3 2 0 These two graphics were
- Page 31 and 32: Since we don't consider this unfill
- Page 33 and 34: First there is the concept of varia
- Page 35 and 36: 1.8 Loops Yet another programming c
- Page 37 and 38: If in the definition of doublescale
- Page 39 and 40: test (a) (b) (c) (d) ; test (a,b) (
- Page 41 and 42: If you forget about the colors, the
- Page 43 and 44: linejoin=mitered linecap=butt linej
- Page 45 and 46: 1.15 Text Most dashpatterns can be
- Page 47 and 48: Z13 Z24 Z14 Z1 Z12 Z2 Z21 Z23 Z11 Z
- Page 49 and 50: 3 Because we want to call this macr
- Page 51 and 52: dotlabel.rt ("$Z_{3}$", z3) ; dotla
- Page 53 and 54: A different approach is to use a tw
- Page 55 and 56: The graphic extends beyond the boun
- Page 57 and 58: p := (p shifted (5cm,0)) randomized
4<br />
Content<br />
9 Functions . . . . . . . . . . . . . . . . . . . . . 211<br />
9.1 Overview . . . . . . . . . . . . . . . . . . . 211<br />
9.2 Grids . . . . . . . . . . . . . . . . . . . . . . . 213<br />
9.3 Drawing functions . . . . . . . . . . . 216<br />
10 Typesetting in METAPOST . . . . . . 225<br />
10.1 The process . . . . . . . . . . . . . . . . . 225<br />
10.2 Environments . . . . . . . . . . . . . . . 225<br />
10.3 Labels . . . . . . . . . . . . . . . . . . . . . . 226<br />
10.4 TEX text . . . . . . . . . . . . . . . . . . . . 227<br />
10.5 Talking to TEX . . . . . . . . . . . . . . . 238<br />
10.6 Libraries . . . . . . . . . . . . . . . . . . . . 247<br />
11 Debugging . . . . . . . . . . . . . . . . . . . . 255<br />
12 Defining styles . . . . . . . . . . . . . . . . 261<br />
12.1 Adaptive buttons . . . . . . . . . . . . 261<br />
13 A few applications . . . . . . . . . . . . . 271<br />
13.1 Simple drawings . . . . . . . . . . . . . 271<br />
13.2 Free labels . . . . . . . . . . . . . . . . . . 274<br />
13.3 Marking angles . . . . . . . . . . . . . . 279<br />
13.4 Color circles . . . . . . . . . . . . . . . . 285<br />
13.5 Fool yourself . . . . . . . . . . . . . . . . 292<br />
13.6 Growing graphics . . . . . . . . . . . . 296<br />
13.7 Simple Logos . . . . . . . . . . . . . . . . 304<br />
13.8 Music sheets . . . . . . . . . . . . . . . . 309<br />
13.9 The euro symbol . . . . . . . . . . . . . 310<br />
13.10 Killing time . . . . . . . . . . . . . . . . . 314<br />
14 METAFUN macros . . . . . . . . . . . . . 319<br />
A METAPOST syntax . . . . . . . . . . . . . 321<br />
A.1 Syntax diagrams . . . . . . . . . . . . . 321<br />
A.2 Left overs . . . . . . . . . . . . . . . . . . . 331<br />
B This document . . . . . . . . . . . . . . . . 333<br />
C Reference . . . . . . . . . . . . . . . . . . . . . 335<br />
C.1 Paths . . . . . . . . . . . . . . . . . . . . . . . 335<br />
C.2 Transformations . . . . . . . . . . . . . 346<br />
C.3 Points . . . . . . . . . . . . . . . . . . . . . . 357<br />
C.4 Attributes . . . . . . . . . . . . . . . . . . . 359<br />
C.5 Text . . . . . . . . . . . . . . . . . . . . . . . . 364<br />
C.6 Graphics . . . . . . . . . . . . . . . . . . . . 366<br />
D Literature . . . . . . . . . . . . . . . . . . . . . 367<br />
D.1 METAFONT and METAPOST . . 367<br />
D.2 TEX . . . . . . . . . . . . . . . . . . . . . . . . 367<br />
D.3 CONTEXT . . . . . . . . . . . . . . . . . . 367<br />
D.4 Tools . . . . . . . . . . . . . . . . . . . . . . . 368<br />
D.5 Distributions . . . . . . . . . . . . . . . . 368<br />
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . 369