meta-fig.mkiv /size: 2146 b    last modification: 2021-10-28 13:50
1%D \module
2%D   [       file=meta-fig,
3%D        version=2000.09.07,
4%D          title=\METAPOST\ Graphics,
5%D       subtitle=Stand Alone Graphics,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14\writestatus{loading}{MetaPost Graphics / Stand Alone Graphics}
15
16\unprotect
17
18%D This module implements a method for defining
19%D stand||alone||graphics, that is, each graphic gets is own
20%D page. Because graphics are wrapped in a \type {\framed},
21%D you can add overlays to the graphic directly, and since the
22%D whole \CONTEXT\ machinery is available, you can also add
23%D page backgrounds.
24%D
25%D \starttyping
26%D \setupMPpage
27%D   [offset=1pt,
28%D    background=color,
29%D    backgroundcolor=green]
30%D
31%D \startMPpage
32%D   fill fullcircle scaled 10cm withcolor red ;
33%D \stopMPpage
34%D
35%D \startMPpage
36%D   fill fullsquare rotated 45 scaled 8cm withcolor blue ;
37%D \stopMPpage
38%D \stoptyping
39%D
40%D Although this is hardly of any use, you can mix these
41%D definitions with the text flow, since all settings are
42%D kept local. The page is clipped to the image size.
43
44\definefittingpage
45  [MPpage]
46  [\c!align=,
47   \c!command=\meta_process_graphic_command,
48   \c!instance=]
49
50\unexpanded\def\setupMPpage
51  {\setupfittingpage[MPpage]}
52
53\unexpanded\def\meta_process_graphic_command
54  {\doif{\fittingpageparameter\c!alternative}\v!offset
55     {\def\meta_relocate_graphic{\clf_setpageorigin\MPllx\MPlly\relax}}%
56   \meta_process_graphic_instance{\fittingpageparameter\c!instance}}
57
58%D \macros
59%D  {MPfigure}
60%D
61%D A bit out of place, here but nevertheless:
62
63\unexpanded\def\MPfigure#1#2% test for dup figure, can be replaced by a textext
64  {\bgroup
65   \getfiguredimensions[#1]% [\c!object=\v!no] already set
66   \startMPcode
67     draw externalfigure "#1"
68       xsized \the\dimexpr\figurewidth \relax\space % must be points
69       ysized \the\dimexpr\figureheight\relax\space % must be points
70       #2 ;
71   \stopMPcode
72   \egroup}
73
74\protect \endinput
75