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.

214<br />

draw hlingrid(0, 10, 1, 3cm, 3cm) slanted .5 ;<br />

draw vlingrid(0, 10, 1, 3cm, 3cm) slanted .5 ;<br />

Using macros like these often involves a bit of trial and error. The arguments to these macros are<br />

as follows:<br />

hlingrid (Min, Max, Step, Length, Width)<br />

vlingrid (Min, Max, Step, Length, Height)<br />

hloggrid (Min, Max, Step, Length, Width)<br />

vloggrid (Min, Max, Step, Length, Height)<br />

The macros take the following text upto the semi--colon into account and return a picture. We will<br />

now apply this knowledge to a more meaningful example. First we draw a grid.<br />

You can use the grid drawing macros to produce your own paper, for instance using the following<br />

mixed TEX--METAFUN code:<br />

\startMPpage<br />

StartPage ;<br />

width := PaperWidth ; height := PaperHeight ; unit := cm ;<br />

drawoptions(withpen pencircle scaled .2pt withcolor .8white) ;<br />

draw vlingrid(0, width /unit, 1/10, width, height) ;<br />

draw hlingrid(0, height/unit, 1/10, height, width ) ;<br />

drawoptions(withpen pencircle scaled .5pt withcolor .4white) ;<br />

draw vlingrid(0, width /unit, 1, width, height) ;<br />

draw hlingrid(0, height/unit, 1, height, width ) ;<br />

StopPage ;<br />

\stopMPpage<br />

This produces a page (as in figure 9.1) with a metric grid. If you're hooked to the inch, you can<br />

set unit := 1in. If you want to process this code, you need to wrap it into the normal document<br />

producing commands:<br />

\setupoutput[pdftex]<br />

\setupcolors[state=start]<br />

\starttext<br />

... definitions ...<br />

\stoptext<br />

Functions Grids

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

Saved successfully!

Ooh no, something went wrong!