summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/context/manuals/reference/en/co-metapost.tex
blob: 1eee3555910e6647fda52606a94ca9a36a0eab98 (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
\startcomponent co-metapost

\startbuffer[mp-1]
\startMPgraphic
  fill unitsquare scaled 100 withcolor (.2,.3,.4) ;
\stopMPgraphic
\stopbuffer

\startbuffer[mp-2]
\startMPgraphic
  fill unitsquare scaled 100 withcolor \MPcolor{mark} ;
\stopMPgraphic
\stopbuffer

\startbuffer[mp-3]
\startuseMPgraphic{test a}
  fill unitsquare xscaled \overlaywidth yscaled \overlayheight ;
\stopuseMPgraphic

\defineoverlay[A Nice Rectangle][\useMPgraphic{test a}]

\setupbackgrounds[page][background=A Nice Rectangle]
\stopbuffer

\startbuffer[mp-4]
\startreusableMPgraphic{test b}
  fill unitsquare xscaled \overlaywidth yscaled \overlayheight ;
\stopreusableMPgraphic

\defineoverlay[A Nice Rectangle][\reuseMPgraphic{test b}]

\setupbackgrounds[page][background=A Nice Rectangle]
\stopbuffer


\environment contextref-env
\product contextref

\chapter[metapost]{\METAPOST}

In a \CONTEXT\ document we can use \METAPOST\ code
directly. For example:

\typebuffer[mp-1]

A direct relation with the \CONTEXT\ color mechanism is
obvious:

\typebuffer[mp-2]

\METAPOST\ support is very extensive. You can store
definitions and re||use them at random. If possible
processed \METAPOST\ pictures are re||used.

A detailed discussion on embedding \METAPOST\ graphics is
beyond this manual, and therefore will be covered elsewhere.
For the moment it is enough to know the basics of putting
for instance graphics in the background. In the next example,
a graphic is calculated each time it is refered to:

\typebuffer[mp-3]

When the graphic does not change, we can best reuse it, like:

\typebuffer[mp-4]

When using the \CONTEXT\ command line interface \TEXEXEC,
graphics are processed automatically. Unless one calls
\METAPOST\ at runtime, a second pass is needed to get the
graphics in their final state.

\stopcomponent