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.

66<br />

We can view this file in a POSTSCRIPT viewer like GHOSTVIEW or convert the graphic to PDF (using<br />

mptopdf) and view the result in a suitable PDF viewer like ACROBAT. Of course, you can embed<br />

such a file in a CONTEXT document, using a command like:<br />

\externalfigure[yourfile.7]<br />

We will go in more detail about embedding graphics in chapter 3.<br />

If you have installed CONTEXT, somewhere on your system there resides a file mp-tool.mp. If you<br />

make a stand--alone graphic, it's best to put the following line at the top of your file:<br />

input mp-tool ; % or input metafun ;<br />

By loading this file, the resulting graphic will provide a high resolution bounding box, which enables<br />

more accurate placement. The file also sets the prologues := 1 so that viewers like GHOST-<br />

VIEW can refresh the file when it is changed.<br />

Next we will introduce some more METAPOST commands. From now on, we will omit the encapsulating<br />

beginfig and endfig macros. If you want to process these examples yourself, you should<br />

add those commands yourself, or if you use CONTEXT you don't need them at all.<br />

pickup pencircle scaled .5cm ;<br />

draw unitsquare xscaled 8cm yscaled 1cm withcolor .625white ;<br />

draw origin withcolor .625yellow ;<br />

pickup pencircle scaled 1pt ;<br />

draw bbox currentpicture withcolor .625red ;<br />

In this example we see a mixture of so called primitives as well as macros. A primitive is something<br />

hard coded, a built--in command, while a macro is a collection of such primitives, packaged in a<br />

way that they can be recalled easily. Where scaled is a primitive and draw a macro, unitsquare<br />

is a path variable, an abbreviation for:<br />

unitsquare = (0,0) -- (1,0) -- (1,1) -- (0,1) -- cycle ;<br />

The double dash (--) is also a macro, used to connect two points with a straight line segment.<br />

However, cycle is a primitive, which connects the last point of the unitsquare to the first on unitsquare's<br />

path. Path variables must first be declared, as in:<br />

path unitsquare ;<br />

A large collection of such macros is available when you launch METAPOST. Consult the METAPOST<br />

manual for details.<br />

In the first line of our example, we set the drawing pen to .5cm. You can also specify such a<br />

dimension in other units, like points (pt). When no unit is provided, METAPOST will use a big point<br />

(bp) , the POSTSCRIPT approximation of a point.<br />

A few more details Making graphics

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

Saved successfully!

Ooh no, something went wrong!