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.

232<br />

Placing the pictures is now rather easy:<br />

\startMPdrawing<br />

for i=1 upto n :<br />

draw pic[i] shifted (-radius,0) rotatedaround(origin,rot[i]) ;<br />

endfor ;<br />

\stopMPdrawing<br />

The pictures are now positioned on half a circle, properly kerned.<br />

MetaPost is Fun!<br />

A bit more insight is given in the next picture:<br />

MetaPost is Fun!<br />

This was defined as follows. The path variable tcycle is predefined to the top half of a fullcircle.<br />

\startMPdrawing<br />

def moved(expr i) =<br />

shifted (-radius,0) rotatedaround(origin,rot[i])<br />

enddef ;<br />

pickup pencircle scaled .5pt ;<br />

for i=1 upto n :<br />

draw pic[i] moved(i) ;<br />

draw boundingbox pic[i] moved(i) withcolor red ;<br />

draw origin -- center pic[i] moved(i) withcolor green ;<br />

endfor ;<br />

draw tcircle scaled 2r withcolor blue ;<br />

\stopMPdrawing<br />

We will now package all of this into a nice, efficient macro, using, of course, the predefined scratch<br />

registers \MPtoks and \MPbox. First we define the token processor. Note again the expansion<br />

inhibition switch [-].<br />

\def\processrotationtoken#1%<br />

{\appendtoks#1\to\MPtoks<br />

\setbox\MPbox=\hbox{\RotFont\the\MPtoks}%<br />

\startMPdrawing<br />

Typesetting in METAPOST TEX text

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

Saved successfully!

Ooh no, something went wrong!