29.11.2012 Views

MetaFun - Pragma ADE

MetaFun - Pragma ADE

MetaFun - Pragma ADE

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

pab := pab cutafter (pab intersectionpoint pb) ;<br />

pickup pencircle scaled 1pt ;<br />

draw pab withcolor .625yellow ;<br />

anchor_box(\MPanchor{\MPvar{from}}) ;<br />

fi ;<br />

\stopMPpositiongraphic<br />

The command \startMPpositiongraphic defines a graphic, in this example we have called it<br />

mypos:circle.<br />

The METAPOST macro initialize_box returns the characteristics of the box as identified by \MPpos.<br />

After this call, the corners are available in llxy, lrxy, urxy and ulxy. The center is defined by cxy<br />

and the path stored in pxy. When we are finished drawing the graphic, we can anchor the result<br />

with anchor_box. This macro automatically handles positioning on specific layers.<br />

The position macro \MPpos returns the current characteristics of a position. The previously defined<br />

G positions return:<br />

position page x y width height depth<br />

G-1 149 182.84163pt 287.9047pt 31.97pt 7.26pt 2.83pt<br />

G-2 149 110.1036pt 275.33267pt 21.15999pt 4.69pt 2.83pt<br />

G-3 149 228.85555pt 275.33267pt 27.68001pt 7.26pt 0.2pt<br />

G-4 149 368.61012pt 262.76065pt 16.46999pt 6.21pt 0.2pt<br />

The numbers represent the real pagenumber p, the current position (x,y), and the dimensions of<br />

the box (w,h,d) if known. These values are fed directly into METAPOST graphics but the individual<br />

components can be asked for by \MPp, \MPx, \MPy, \MPw, \MPh and \MPd.<br />

In the previous definition of the graphic, we saw another macro, \MPvar. When we invoke a<br />

graphic or attach a graphic to a layer, we can pass variables. We can also set specific variables<br />

in other ways, as we will see later.<br />

\setMPpositiongraphic{G-1}{mypos:circle}<br />

\setMPpositiongraphic{G-1}{mypos:line}{to=G-2}<br />

In the second definition, we let the variable to point to another position. When needed, we can<br />

ask for the value of to by \MPvar{to}. For reasons of convenience, the current position is assigned<br />

automatically to from and self. This means that in the line we saw in the graphic:<br />

initialize_box(\MPpos{\MPvar{self}}) ;<br />

\MPvar{self} will return the current position, which, fed to \MPpos will return the list of positional<br />

numbers. We already warned the reader: this is not an easy chapter.<br />

5.3 More layers<br />

Overlays are one of the nicer features of CONTEXT and even more nice things can be build on top of<br />

them. Overlays are defined first and then assigned to framed boxes using the background variable.<br />

You can stack overlays, which is why they are called as such. You can use the special overlay called<br />

foreground to move the topmost (often text) layer down in the stack.<br />

More layers Positional graphics<br />

147

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!