29.11.2012 Views

MetaFun - Pragma ADE

MetaFun - Pragma ADE

MetaFun - Pragma ADE

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

56<br />

Often I make such helpers in the process of writing larger drawing systems. Take crossed:<br />

path p ; p := origin crossed 1cm ;<br />

drawpath p ; drawpoints p ;<br />

p := (origin crossed fullcircle scaled 2cm crossed .5cm) shifted (3cm,0) ;<br />

drawpath p ; drawpoints p ;<br />

These examples demonstrate that a path is made up out of points (something that you probably<br />

already knew by now). The METAPOST operator of can be used to ‘access' a certain point at a curve.<br />

4<br />

3<br />

path p ; p := fullsquare xyscaled (3cm,2cm) randomized .5cm ;<br />

drawpath p ; drawpoints p ; drawpointlabels p ;<br />

draw point 2.25 of p withpen pencircle scaled 5mm withcolor .625red ;<br />

0<br />

2<br />

1<br />

To this we add two more operators: on and along. With on you get the point at the supplied<br />

distance from point 0; with along you get the point at the fraction of the length of the path.<br />

path p, q, r ;<br />

p := fullsquare xyscaled (2cm,2cm) randomized .5cm ;<br />

q := p shifted (3cm,0) ; r := q shifted (3cm,0) ;<br />

drawpath p ; drawpoints p ; drawpointlabels p ;<br />

drawpath q ; drawpoints q ; drawpointlabels q ;<br />

drawpath r ; drawpoints r ; drawpointlabels r ;<br />

pickup pencircle scaled 5mm ;<br />

draw point 2.25 of p withcolor .625red ;<br />

draw point 2.50cm on q withcolor .625yellow ;<br />

draw point .45 along r withcolor .625white ;<br />

Beware: the length of a path is the number of points minus one. The shapes below are constructed<br />

from 5 points and a length of 4. If you want the length as dimension, you should use arclength.<br />

3<br />

4<br />

0<br />

3<br />

2<br />

1<br />

4<br />

0<br />

3<br />

2<br />

1<br />

4<br />

Welcome to MetaPost Some extensions<br />

0<br />

We will now play a bit with simple lines. With cutends, you can (indeed) cut off the ends of a<br />

curve. The specification is a dimension.<br />

2<br />

1

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

Saved successfully!

Ooh no, something went wrong!