metafun-conventions.tex /size: 3896 b    last modification: 2023-12-21 09:43
1% language=us runpath=texruns:manuals/metafun
2
3\startcomponent metafun-conventions
4
5\environment metafun-environment
6
7\startchapter[title={Conventions}]
8
9\index {running}
10\index {processing}
11
12When reading this manual, you may be tempted to test the examples shown. This can
13be done in several ways. You can make a file and process that file by \METAPOST.
14Such a file looks like:
15
16\starttyping
17beginfig(1) ;
18  fill fullcircle scaled 5cm withcolor red ; % a graphic
19endfig ;
20
21end .
22\stoptyping
23
24Don't forget the semi||colons that end the statements. If the file is saved as
25\type {yourfile.mp}, then the file can be processed. Before we process this file,
26we first need to load some basic \METAPOST\ definitions, because the built in
27repertoire of commands is rather limited. Such a set is called a format. The
28standard format is called {metapost} but we will use a more extensive set of
29macros \type {metafun}. In the past such a set was converted into a \type {mem}
30file and running the above file was done with:
31
32\starttyping
33mpost --mem=metafun.mem yourfile
34\stoptyping
35
36However, this is no longer the case and macros need to be loaded at startup as
37follows:
38
39\starttyping
40mpost --ini metafun.mpii yourfile.mp
41\stoptyping
42
43Watch the suffix \type {mpii}: this refers to the stand alone, the one that
44doesn't rely on \LUATEX.
45
46After the run the results are available in \type {yourfile.1} and can be viewed
47with \GHOSTSCRIPT. You don't need to close the file so reprocessing is very
48convenient.
49
50Because we will go beyond standard \METAPOST, we will use the \type {mpiv} files.
51These work with the library which in turn means that we will run from within
52\CONTEXT. This has the advantage that we also have advanced font support at our
53hands. In that case, a simple file looks like:
54
55\starttyping
56\starttext
57  \startMPpage
58    fill fullcircle scaled 5cm withcolor red ;
59  \stopMPpage
60  \startMPpage
61    fill unitsquare scaled 5cm withcolor red ;
62  \stopMPpage
63\stoptext
64\stoptyping
65
66If the file is saved as \type {yourfile.tex}, then you can produce a \PDF\ file
67with: \footnote {In fact, you could also process the \METAPOST\ file directly
68because the \type {context} script will recognize it as such and wrap it into
69a page.}
70
71\starttyping
72context yourfile
73\stoptyping
74
75The previous call will use \LUATEX\ and \CONTEXT\ \MKIV\ to produce a file with
76two pages using the built in \METAPOST\ library with \METAFUN. When you use this
77route you will automatically get the integrated text support shown in this
78manual, including \OPENTYPE\ support. If one page is enough, you can also say:
79
80\starttyping
81\startMPpage
82fill fullcircle scaled 5cm withcolor red ;
83\stopMPpage
84\stoptyping
85
86So when you have a running \CONTEXT\ on your system you don't need to bother
87about installing \METAPOST\ and running \METAFUN.
88
89We will use lots of color. Don't worry if your red is not our red, or your yellow
90does not match ours. We've made color definitions to match the overall design of
91this document, but you should feel free to use any color of choice in the
92upcoming examples.
93
94By default, \CONTEXT\ has turned its color mechanism on. If you don't want your
95graphics to have color, you should say:
96
97\starttyping
98\setupcolors[state=stop]
99\stoptyping
100
101but in todays documents color is so normal that you will probably never do that.
102Because \METAFUN\ hooks into the \CONTEXT\ color mechanism, you can also use its
103color space and conversion related features.
104
105You need to keep in mind that just like \CONTEXT\ \MKII\ is frozen, the \type
106{mpii} macros are also not extended. From now on we assume that you use \CONTEXT\
107\MKIV\ which exclusively uses \type {mpiv} macros.
108
109Even if you want to use \METAFUN\ but not \CONTEXT, you can still best use the
110mentioned page method as it will give you decent text processing. You need to
111know (and use) only a few \CONTEXT\ commands then.
112
113\stopchapter
114
115\stopcomponent
116