MetaFun - Pragma ADE
MetaFun - Pragma ADE MetaFun - Pragma ADE
126 Embedded graphics Managing resources
4 Enhancing the layout One of the most powerful and flexible commands of CONTEXT is \framed. We can use the background features of this command to invoke and position graphics that adapt themselves to the current situation. Once understood, overlays will become a natural part of the CONTEXT users toolkit. 4.1 Overlays Many CONTEXT commands support overlays. The term overlay is a bit confusing, since such an overlay in most cases will lay under the text. However, because there can be many layers on top of each other, the term suits its purpose. When we want to put a METAPOST graphic under some text, we go through a three step process. First we define the graphic itself: \startuniqueMPgraphic{demo circle} path p ; p := fullcircle xscaled \overlaywidth yscaled \overlayheight ; fill p withcolor .85white ; draw p withpen pencircle scaled 2pt withcolor .625red ; \stopuniqueMPgraphic This graphic will adapt itself to the width and height of the overlay. Both \overlaywidth and \overlayheight are macros that return a dimension followed by a space. The next step is to register this graphic as an overlay. \defineoverlay[demo circle][\uniqueMPgraphic{demo circle}] We can now use this overlay in any command that provides the \framed functionality. Since this graphic is defined as unique, CONTEXT will try to reuse already calculated and embedded graphics when possible. \framed[background=demo circle]{This text is overlayed.} The background can be set to color, screen, an overlay identifier, like demo circle, or a comma separated list of those. This text is overlayed. The \framed command automatically draws a ruled box, which can be quite useful when debugging a graphic. However, in this case we want to turn the frame off. \framed [background=demo circle,frame=off] {This text is overlayed.} This text is overlayed. Overlays Enhancing the layout 127
- Page 79 and 80: Especially when a path results from
- Page 81 and 82: points first order curve second ord
- Page 83 and 84: first iteration second iteration th
- Page 85 and 86: and get: We don't even need that mu
- Page 87 and 88: Figure 2.3 Circles with minimized i
- Page 89 and 90: The tension specifier can be used t
- Page 91 and 92: The asymetrical tensions are less p
- Page 93 and 94: z0 .. z1 .. z2 z0 {curl 1} .. z1 ..
- Page 95 and 96: 7 In literature concerning POSTSCRI
- Page 97 and 98: currentpicture := currentpicture sl
- Page 99 and 100: We can achieve this by defining poi
- Page 101 and 102: We're still not there. Like in a pr
- Page 103 and 104: Due to the thicker line width used
- Page 105 and 106: left up down right The previous def
- Page 107 and 108: Here the & glues strings together,
- Page 109 and 110: picture p ; p := "MetaFun" normalin
- Page 111 and 112: pickup pencircle scaled 2pt ; draw
- Page 113 and 114: Because the z--variables are used f
- Page 115 and 116: 3 Embedded graphics In addition to
- Page 117 and 118: \startMPcode fill fullcircle scaled
- Page 119 and 120: \startuniqueMPgraphic{right or wron
- Page 121 and 122: {\externalfigure[mprun:extrafun::my
- Page 123 and 124: \startlinecorrection[blank] \proces
- Page 125 and 126: In order to prevent problems, we ad
- Page 127 and 128: There are a few more low level swit
- Page 129: When we convert color to gray, we u
- Page 133 and 134: 4.2 Overlay variables [offset=3pt,f
- Page 135 and 136: This background demonstrates that a
- Page 137 and 138: As you may know, TEX's ambassador i
- Page 139 and 140: This works as expected: \RotatedTex
- Page 141 and 142: We will now apply this knowledge of
- Page 143 and 144: p := p shifted (2o,OverlayHeight-yp
- Page 145 and 146: We demonstrated that when defining
- Page 147 and 148: 5 Positional graphics In this chapt
- Page 149 and 150: 5.2 Anchors and layers In a previou
- Page 151 and 152: pab := pab cutafter (pab intersecti
- Page 153 and 154: fill p withcolor \MPcolor{lightgray
- Page 155 and 156: The previous example also demonstra
- Page 157 and 158: \setMPlayer [test] [somepos-1] [loc
- Page 159 and 160: 6 Page backgrounds Especially in in
- Page 161 and 162: As soon as you want to make an elec
- Page 163 and 164: do_it (1,4,false) ; do_it (5,4,fals
- Page 165 and 166: gigigi Watch how the bounding boxes
- Page 167 and 168: You can test this concept yourself
- Page 169 and 170: StartPage ; fill Area[Text][Text] s
- Page 171 and 172: fi ; Main := Main enlarged 6pt ; pi
- Page 173 and 174: ulcorner Field[Text] [Text] -urcorn
- Page 175 and 176: The left picture demonstrates what
- Page 177 and 178: There are two more operators: inner
- Page 179 and 180: 7 Shapes, symbols and buttons One c
4 Enhancing the layout<br />
One of the most powerful and flexible commands of CONTEXT is \framed. We can use the background<br />
features of this command to invoke and position graphics that adapt themselves to the current situation.<br />
Once understood, overlays will become a natural part of the CONTEXT users toolkit.<br />
4.1 Overlays<br />
Many CONTEXT commands support overlays. The term overlay is a bit confusing, since such an<br />
overlay in most cases will lay under the text. However, because there can be many layers on top<br />
of each other, the term suits its purpose.<br />
When we want to put a METAPOST graphic under some text, we go through a three step process.<br />
First we define the graphic itself:<br />
\startuniqueMPgraphic{demo circle}<br />
path p ;<br />
p := fullcircle xscaled \overlaywidth yscaled \overlayheight ;<br />
fill p withcolor .85white ;<br />
draw p withpen pencircle scaled 2pt withcolor .625red ;<br />
\stopuniqueMPgraphic<br />
This graphic will adapt itself to the width and height of the overlay. Both \overlaywidth and<br />
\overlayheight are macros that return a dimension followed by a space. The next step is to<br />
register this graphic as an overlay.<br />
\defineoverlay[demo circle][\uniqueMPgraphic{demo circle}]<br />
We can now use this overlay in any command that provides the \framed functionality. Since this<br />
graphic is defined as unique, CONTEXT will try to reuse already calculated and embedded graphics<br />
when possible.<br />
\framed[background=demo circle]{This text is overlayed.}<br />
The background can be set to color, screen, an overlay identifier, like demo circle, or a comma<br />
separated list of those.<br />
This text is overlayed.<br />
The \framed command automatically draws a ruled box, which can be quite useful when debugging<br />
a graphic. However, in this case we want to turn the frame off.<br />
\framed<br />
[background=demo circle,frame=off]<br />
{This text is overlayed.}<br />
This text is overlayed.<br />
Overlays Enhancing the layout<br />
127