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.

text text text<br />

text text<br />

text<br />

text<br />

text<br />

text<br />

text<br />

text<br />

textextext text<br />

text<br />

The original label macros permits us to align the label at positions, 4 corners and 4 points halfway<br />

the sides. It happens that circles are also composed of 8 points. Because in most cases the label is<br />

to be positioned in the direction of the center of a curve and the point at hand, it makes sense to<br />

take circles as the starting points for positioning the labels.<br />

To help us in positioning, we define a special square path, freesquare. This path is constructed<br />

out of 8 points that match the positions that are used to align labels.<br />

path freesquare ;<br />

freesquare := ((-1,0)--(-1,-1)--(0,-1)--(+1,-1)--<br />

(+1,0)--(+1,+1)--(0,+1)--(-1,+1)--cycle) scaled .5 ;<br />

We now show this free path together with a circle, using the following definitions:<br />

drawpath fullcircle scaled 3cm ;<br />

drawpoints fullcircle scaled 3cm ;<br />

drawpointlabels fullcircle scaled 3cm ;<br />

currentpicture := currentpicture shifted (5cm,0) ;<br />

drawpath freesquare scaled 3cm ;<br />

drawpoints freesquare scaled 3cm ;<br />

drawpointlabels freesquare scaled 3cm ;<br />

We use two drawing macros that are part of the suite of visual debugging macros.<br />

8<br />

7<br />

0<br />

6<br />

1 2 3<br />

5<br />

4<br />

4<br />

3<br />

5<br />

2<br />

6<br />

As you can see, point 1 is the corner point that suits best for alignment when a label is put at point 1<br />

of the circle. We will now rewrite thefreelabel in such a way that the appropriate point of the<br />

associated freesquare is found.<br />

vardef thefreelabel (expr str, loc, ori) =<br />

save s, p, q, l ; picture s ; path p, q ; pair l ;<br />

s := thelabel(str,loc) ;<br />

0<br />

1<br />

7<br />

Free labels A few applications<br />

8<br />

277

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

Saved successfully!

Ooh no, something went wrong!