summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/base/source/grdemo.ms
blob: fbcbfaceff40c3eee48d6760a94625bf32fb38fd (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
.nr PS 11
.nr VS 13
.TL
MetaPost with groff 
.LP
Since MetaPost is a picture-drawing language that outputs PostScript,
it is necessary to use the
.ft CW
-mpspic
.ft
macro package, which is automatically included when \fIgroff\fR 
is invoked with the
.ft CW
-Tps
.ft 
option to prepare output for PostScript printers or previewers.
.PP
Suppose you have written some figures in MetaPost and placed
the input in a file \f(CWfigures.mp\fR.
Running
.nf
.ft CW
             mp -T figures
.ft
.fi
to invoke the MetaPost interpreter produces output files
\f(CWfigures.1\fR, \f(CWfigures.2\fR, .\|.\|. 
which can be included in a \fIgroff\fR document via macro calls 
such as
.nf
.ft CW
            .PSPIC figures.1 width height
.ft
.fi
as explained in the \fIgrops\fR(1) documentation. 
Note that the picture gets rescaled if the height and width
in the \f(CW.PSPIC\fR command don't match \fImp\fR's idea of 
the picture dimensions.
.PP
For instance,
.PSPIC figs.1 1.5i 1.08i
this figure was derived from a file
.ft CW
figs.mp
.ft
and included at this point by invoking the \f(CW.PSPIC\fR macro 
with height 1.08 inches and width 1.5 inches.  
.PP
The file
.ft CW
figs.mp
.ft
looks like this:
.nf
.ft CW
.nr PS 9
.nr VS 11
prologues:=1;
input boxes
beginfig(1);
pair shadowshift; shadowshift=(1,-1)*bp;

def drawshadowed(text t) =
  forsuffixes $=t:
    fill bpath$ shifted shadowshift;
    unfill bpath$;
    drawboxed($);
  endfor
enddef;

boxit.a(btex \\s8A\\s+2 \\(lh a etex);
circleit.b(btex $e sup {i omega t}$ etex rotated 20);
b.w - a.e = (10bp,0);
drawshadowed(a,b);
draw a.e..b.w;

draw bbox currentpicture dashed evenly;
endfig;
.nr PS 11
.nr VS 13
.ft
.fi
.PP
Note that the typesetting commands in the
\f(CWbtex\fR.\|.\|.\f(CWetex\fR blocks in the above example 
are processed by
.nf
.ft CW
             eqn -d\\$\\$ | troff -Tpost
.ft
.fi
If a different \fItroff\fR pipeline is desired, it can be specified 
via the
.ft CW
TROFF
.ft
environment variable.  For example,
.nf
.ft CW
             TROFF='tbl | eqn -d\\$\\$ | troff -Tpost'
.ft
.fi
adds \fItbl\fR to the pipeline in addition to \fIeqn\fR.
.PP
Macro definitions and such can be added via the standard
\f(CWverbatimtex\fR.\|.\|.\f(CWetex\fR mechanism that adds the 
given material to the \fItroff\fR input.  Such material should 
not generate any output since this would get mixed up with the 
next \f(CWbtex\fR.\|.\|.\f(CWetex\fR block.  Thus, newlines between 
\f(CWverbatimtex\fR and \f(CWetex\fR must be protected with \f(CW\\\fR.
.PP
Unfortunately, typesetting of \f(CWbtex\fR.\|.\|.\f(CWetex\fR blocks
currently doesn't work with \fIgroff\fR and equires a UNIX
\fItroff\fR implementation, because MetaPost's \f(CWdmp\fR
post-processor can't handle \fIgroff\fR's extended font and output
file formats documented in \fIgroff_font\fR(5) and \fIgroff_out\fR(5).
Nevertheless, using \fItroff\fR to prepare figures with MetaPost 
and \fIgroff\fR to typeset them may still be a useful combination 
if your \fItroff\fR implementation doesn't provide the
.ft CW
-mpictures
.ft 
macro packages.