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.

24<br />

The dir command returns an unit vector, which is why the first two shapes look different and are<br />

smaller than the third one. We can compensate for that by an additional scaling:<br />

pickup pencircle scaled 2mm ;<br />

draw (origin -- dir(45) -- dir(0) -- cycle)<br />

scaled sqrt(2) scaled 3cm withcolor .625red ;<br />

draw (origin -- dir(angle(1,1)) -- dir(angle(1,0)) -- cycle)<br />

scaled sqrt(2) scaled 3cm shifted (4.5cm,0) withcolor .625yellow ;<br />

draw (origin -- (1,1) -- (1,0) -- cycle)<br />

scaled 3cm shifted (9cm,0) withcolor .625white ;<br />

1.5 Drawing pictures<br />

Once a path is defined, either directly or as a variable, you can turn it into a picture. You can draw<br />

a path, like we did in the previous examples, or you can fill it, but only if it is closed.<br />

0<br />

3<br />

1<br />

2<br />

Drawing is done by applying the draw command to a path, as in:<br />

draw (0cm,1cm)..(2cm,2cm)..(4cm,0cm)..cycle ;<br />

The rightmost graphic was made with fill:<br />

fill (0cm,1cm)..(2cm,2cm)..(4cm,0cm)..cycle ;<br />

If you try to duplicate this drawing, you will notice that you will get black lines instead of red and<br />

a black fill instead of a gray one. When drawing or filling a path, you can give it a color, use all<br />

kinds of pens, and achieve special effects like dashes or arrows.<br />

Welcome to MetaPost Drawing pictures<br />

0<br />

3<br />

1<br />

2

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

Saved successfully!

Ooh no, something went wrong!