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.

68<br />

4<br />

5<br />

pickup pencircle scaled .5cm ;<br />

filldraw unitsquare xscaled 8cm yscaled 1cm withcolor .625white ;<br />

path bb ; bboxmargin := 0pt ; bb := bbox currentpicture ;<br />

draw bb withpen pencircle scaled 1pt withcolor .625red ;<br />

draw origin withpen pencircle scaled 5pt withcolor .625yellow ;<br />

The resulting graphic has the bounding box of the fill. Note how the path, because it is stroked with<br />

a .5cm pen, extends beyond the border of the previous bounding box. The way this image shows<br />

up depends on the viewer (settings) you use to render the graphic. For example, in GHOSTVIEW, if<br />

you disable clipping to the bounding box, only the positive quadrant of the graphic is shown. 4<br />

From the previous examples, you can conclude that the following alternative results in a proper<br />

bounding box:<br />

pickup pencircle scaled .5cm ;<br />

path p ; p := unitsquare xscaled 8cm yscaled 1cm ;<br />

fill p withcolor .625white ;<br />

draw p withcolor .625white ;<br />

path bb ; bboxmargin := 0pt ; bb := bbox currentpicture ;<br />

draw bb withpen pencircle scaled 1pt withcolor .625red ;<br />

draw origin withpen pencircle scaled 5pt withcolor .625yellow ;<br />

The CONTEXT distribution comes with a set of METAPOST modules, one of which contains the<br />

drawfill macro, which provides the outer bounding box. 5 Next we demonstrate its use in another,<br />

more complicated example.<br />

picture finalpicture ; finalpicture := nullpicture ;<br />

numeric n ; n := 0 ; bboxmargin := 0pt ;<br />

pickup pencircle scaled .5cm ;<br />

def shape =<br />

unitsquare scaled 2cm withcolor .625white ;<br />

draw bbox currentpicture<br />

withpen pencircle scaled .5mm withcolor .625red ;<br />

addto finalpicture also currentpicture shifted(n*3cm,0) ;<br />

currentpicture := nullpicture ; n := n+1 ;<br />

enddef ;<br />

Old versions of METAPOST calculated the boundingbox differently for a filldraw: through the middle of the penpath.<br />

Starting from version 1.0 METAPOST calculates the boundingbox differently and the distinction between drawfill and<br />

filldraw is gone. We keep them around both for compatibility.<br />

A few more details Bounding boxes

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

Saved successfully!

Ooh no, something went wrong!