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.

28<br />

often, you may expect draw and fill to be primitives, but they are not. They are macros defined<br />

in terms of primitives.<br />

Given a path pat, you can consider a draw to be defined in terms of:<br />

addto currentpicture doublepath pat<br />

The fill command on the other hand is defined as:<br />

addto currentpicture contour pat<br />

Both macros are actually a bit more complicated but this is mainly due to the fact that they also<br />

have to deal with attributes like the pen and color they draw with.<br />

You can use doublepath and contour directly, but we will use draw and fill whenever possible.<br />

Given a picture pic, the following code is valid:<br />

addto currentpicture also pic<br />

You can add pictures to existing picture variables, where currentpicture is the picture that is<br />

flushed to the output file. Watch the subtle difference between adding a doublepath, contour or<br />

picture.<br />

Here is another nice example of what happens when you fill a path that is partially reversed.<br />

fill fullsquare rotated 45 scaled 2cm<br />

withcolor .625 red ;<br />

fill fullcircle scaled 2cm -- reverse fullcircle scaled 1cm -- cycle<br />

withcolor .625 yellow;<br />

The inner circle is indeed not filled:<br />

1.6 Variables<br />

At this point you may have noted that METAPOST is a programming language. Contrary to some<br />

of today's languages, METAPOST is a simple and clean language. Actually, it is a macro language.<br />

Although METAPOST and TEX are a couple, the languages differ in many aspects. If you are using<br />

both, you will sometimes wish that features present in one would be available in the other. When<br />

using both languages, in the end you will understand why the conceptual differences make sense.<br />

Being written in PASCAL, it will be no surprise that METAPOST has some PASCAL--like features, although<br />

some may also recognize features from ALGOL68 in it.<br />

Welcome to MetaPost Variables

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

Saved successfully!

Ooh no, something went wrong!