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.

Here the & glues strings together, while the decimal operator converts a number into a string.<br />

The result has no typographic beauty —keep in mind that here we use METAPOST to typeset the<br />

text—but the result serves its purpose.<br />

redpart: 0.625<br />

greenpart: 0<br />

bluepart: 0<br />

We can also ask for the path itself (pathpart), the pen (penpart) and the dashpattern (dashpart),<br />

but these can only be assigned to variables of the corresponding type.<br />

A path can be stroked or filled, in which case it is a cyclic path. It can have a non natural bounding<br />

box, be a clip path, consist of line segments or contain text. All these characteristics can be tested.<br />

label.rt("filled: " & condition filled p, (4cm,+1.25cm)) ;<br />

label.rt("stroked: " & condition stroked p, (4cm,+0.75cm)) ;<br />

label.rt("textual: " & condition textual p, (4cm,+0.25cm)) ;<br />

label.rt("clipped: " & condition clipped p, (4cm,-0.25cm)) ;<br />

label.rt("bounded: " & condition bounded p, (4cm,-0.75cm)) ;<br />

label.rt("cycle: " & condition cycle pathpart p, (4cm,-1.25cm)) ;<br />

filled: false<br />

stroked: true<br />

textual: false<br />

clipped: false<br />

bounded: false<br />

cycle: true<br />

In this code snippet, condition is a macro that takes care of translating a boolean value into a<br />

string (like decimal does with a numeric value).<br />

def condition primary b =<br />

if b : "true" else : "false" fi<br />

enddef ;<br />

Clip paths and bounding boxes are kind of special in the sense that they can obscure components.<br />

The following examples demonstrate this. In case of a clip path or bounding box, the pathpart<br />

operator returns this path. In any case that asking for a value does not make sense —a clipping<br />

path for instance has no color— a zero (null) value is returned.<br />

draw fullcircle withpen pencircle scaled 3mm ;<br />

clip currentpicture to fullcircle ;<br />

setbounds currentpicture to fullcircle ;<br />

n: 1 / length: 1 / stroked: false / clipped: true / bounded: false<br />

Analyzing pictures A few more details<br />

103

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

Saved successfully!

Ooh no, something went wrong!