Download METAFUN manual

Transcript
Page 260
Anchors and layers
the text area. Since anchoring the graphics is implemented rather independent of the position of the graphics
themselves, this is no real problem, we can put them all on the page layer, if needed in separate overlays.
How is such a graphic defined? In fact these graphics are a special case of the already present mechanism of
including METAPOST graphics. The circles are defined as follows:
\startMPpositiongraphic{mypos:circle}
initialize_box(\MPpos{\MPvar{self}}) ;
path p ; p := llxy..lrxy..urxy..ulxy..cycle ;
pickup pencircle scaled 1pt ;
fill p withcolor .800white ;
draw p withcolor .625yellow ;
anchor_box(\MPanchor{\MPvar{self}}) ;
\stopMPpositiongraphic
Drawing the lines is handled in a similar fashion.
\startMPpositiongraphic{mypos:line}
path pa, pb, pab ; numeric na, nb ;
initialize_box(\MPpos{\MPvar{from}}) ;
na := nxy ; pa := llxy..lrxy..urxy..ulxy..cycle ;
initialize_box(\MPpos{\MPvar{to}}) ;
nb := nxy ; pb := llxy..lrxy..urxy..ulxy..cycle ;
if na=nb :
pab := center pa -- center pb ;
pab := pab cutbefore (pab intersectionpoint pa) ;
pab := pab cutafter (pab intersectionpoint pb) ;
Positional graphics
exit content index reference Í É Ê Î