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.

240<br />

\startuseMPgraphic{text draw}<br />

draw p withpen pencircle scaled 3pt withcolor red ;<br />

drawarrow l withpen pencircle scaled 1pt withcolor green ;<br />

drawarrow r withpen pencircle scaled 1pt withcolor blue ;<br />

\stopuseMPgraphic<br />

We use \includeMPgraphic to assemble the components:<br />

\startuseMPgraphic{text}<br />

\includeMPgraphic{text path}<br />

\includeMPgraphic{text split}<br />

\includeMPgraphic{text draw}<br />

\stopuseMPgraphic<br />

This graphic is typeset with \useMPgraphic{text}:<br />

Before we are going to use them, we define some variables that specify the text. We use a baseline<br />

distance of 8 points. The part of the line above the baseline is 7.2 points, while the (maximum)<br />

depth is 2.8 points. These ratios are the ones we use in CONTEXT. Because we don't want the text<br />

to touch the circle so we define an offset too also.<br />

\startuseMPgraphic{text vars}<br />

baselineskip := 8pt ;<br />

strutheight := (7.2/10) * baselineskip ;<br />

strutdepth := (2.8/10) * baselineskip ;<br />

offset := baselineskip/2 ;<br />

topskip := strutheight ;<br />

\stopuseMPgraphic<br />

We more of less achieve the offset by scaling the path. In doing so, we use the width and height,<br />

which we call hsize and vsize, thereby conforming to the TEX naming scheme.<br />

First we calculate both dimensions from the bounding box of the path. Next we down scale the<br />

path to compensate for the offset. When done, we recalculate the dimensions.<br />

\startuseMPgraphic{text move}<br />

pair t, b ; path q, l, r ;<br />

hsize := xpart lrcorner p - xpart llcorner p ;<br />

Typesetting in METAPOST Talking to TEX

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

Saved successfully!

Ooh no, something went wrong!