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.

16<br />

draw b withpen pencircle scaled 1mm withcolor .625yellow ;<br />

draw point 0 of a withpen pencircle scaled 2mm ;<br />

draw point 0 of b withpen pencircle scaled 2mm ;<br />

The rotation 120 can be calculated from the relative starting points and time the journey will take.<br />

Alternatively we can use the time along the path, but this would be a bit more fuzzy later on. 16<br />

After a bit of playing with drawing paths between the two points, you decide to make a macro. We<br />

want to feed the angle between the paths but also the connecting path. So, we have to pass a path,<br />

but unfortunately we don't have direct access to the points. By splitting the argument definition<br />

we can pass an expression first, and a wildcard argument next.<br />

\startuseMPgraphic{gamble}<br />

def Gamble (expr rot) (text track) =<br />

path a ; a := fullcircle scaled 3cm ;<br />

path b ; b := fullcircle scaled 2cm rotated rot ;<br />

pair aa ; aa := point 0 of a ;<br />

pair bb ; bb := point 0 of b ;<br />

path ab ; ab := track ;<br />

draw a withpen pencircle scaled 1mm withcolor .625red ;<br />

draw b withpen pencircle scaled 1mm withcolor .625yellow ;<br />

draw aa withpen pencircle scaled 2mm ;<br />

draw bb withpen pencircle scaled 2mm ;<br />

drawarrow ab withpen pencircle scaled 1mm withcolor .625white ;<br />

setbounds currentpicture to boundingbox a enlarged 2mm ;<br />

draw boundingbox currentpicture withpen pencircle scaled .25mm ;<br />

enddef ;<br />

\stopuseMPgraphic<br />

Because at this distance nobody will bother us with the thickness of the pen and colors, we code<br />

them the hard way. We create our own universe by setting a fixed boundingbox.<br />

We leave the Earth in the most popular way, straight upwards and after a few cycles, we leave<br />

it parallel to the surface. The path drawn reminds much of the trajectories shown in popular<br />

magazines.<br />

In case you wonder why METAPOST talks about the time on a path, you now have a cue.<br />

Killing time A few applications<br />

315

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

Saved successfully!

Ooh no, something went wrong!