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.

146<br />

\defineoverlay [foregraphics] [\positionoverlay{foregraphics}]<br />

\defineoverlay [backgraphics] [\positionoverlay{backgraphics}]<br />

\setupbackgrounds<br />

[page]<br />

[background={backgraphics,foreground,foregraphics}]<br />

In this definition, the predefined overlay foreground inserts the page data itself, so the foreground<br />

graphics end up on top. This example also demonstrates that you should be well aware of the way<br />

CONTEXT builds a page. There are six main layers, in some cases with sublayers. The body text goes<br />

into the main text layer, which, unless forced otherwise, lays on top.<br />

1. paper background<br />

2. area backgrounds<br />

3. page backgrounds<br />

4. text areas<br />

5. logo areas<br />

6. main text<br />

The paper background is used for special (sometimes internal) purposes. There are three page<br />

backgrounds: left, right and both. The text areas, logo areas and backgrounds form a 5 × 5 matrix<br />

with columns containing the leftedge, leftmargin, text, rightmargin, and rightedge. The rows of<br />

the matrix contain the top, header, text, footer, and bottom. The main text is what you are reading<br />

now.<br />

Since the page background is applied last, the previous layers can considered to be the foreground<br />

to the page background layer. And, indeed, it is available as an overlay under the name<br />

foreground, as we already saw in the example. Foregrounds are available in most cases, but (for<br />

the moment) not when we are dealing with the text area. Since anchoring the graphics is implemented<br />

rather independent of the position of the graphics themselves, this is no real problem, we<br />

can put them all on the page layer, if needed in separate overlays.<br />

How is such a graphic defined? In fact these graphics are a special case of the already present<br />

mechanism of including METAPOST graphics. The circles are defined as follows:<br />

\startMPpositiongraphic{mypos:circle}<br />

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

path p ; p := llxy..lrxy..urxy..ulxy..cycle ;<br />

pickup pencircle scaled 1pt ;<br />

fill p withcolor .800white ;<br />

draw p withcolor .625yellow ;<br />

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

\stopMPpositiongraphic<br />

Drawing the lines is handled in a similar fashion.<br />

\startMPpositiongraphic{mypos:line}<br />

path pa, pb, pab ; numeric na, nb ;<br />

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

na := nxy ; pa := llxy..lrxy..urxy..ulxy..cycle ;<br />

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

nb := nxy ; pb := llxy..lrxy..urxy..ulxy..cycle ;<br />

if na=nb :<br />

pab := center pa -- center pb ;<br />

pab := pab cutbefore (pab intersectionpoint pa) ;<br />

Positional graphics Anchors and layers

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

Saved successfully!

Ooh no, something went wrong!