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.

42<br />

You can of course rotate, slant and manipulate such a label picture like any other picture.<br />

the right way<br />

The font can be specified in the string defaultfont and the scale in defaultscale. Labels are<br />

defined using the low level operator infont. The next statement returns a picture:<br />

draw "this string will become a sequence of glyphs (MP)"<br />

infont defaultfont scaled defaultscale ;<br />

By default the infont operator is not that clever and does not apply kerning. Also, typesetting<br />

math or accented characters are not supported. The way out of this problem is using btex ...<br />

etex.<br />

draw btex this string will become a sequence of glyphs (\TeX) etex ;<br />

The difference between those two methods is shown below. The outcome of infont depends on<br />

the current setting of the variable defaultfont.<br />

this string will become a sequence of glyphs (MP)<br />

this string will become a sequence of glyphs (TEX)<br />

When you run inside CONTEXT (as we do here) there is no difference between infont and the TEX<br />

methods. This is because we overload the infont operator and also pass its content to TEX. Both<br />

infont and btex use the macro textext which is intercepted and redirects the task to TEX. This<br />

happens in the current run so there is no need to pass extra information about fonts.<br />

Instead of passing strings to infont, you can also pass characters, using char, for example<br />

char(73). When you use infont you normally expect the font to be ASCII conforming. If this<br />

is not the case, you must make sure that the encoding of the font that you use matches your expectations.<br />

However, as we overload this macro it does not really matter since the string is passed<br />

to TEX anyway. For instance, UTF encoded text should work fine as CONTEXT itself understands this<br />

encoding.<br />

1.16 Linear equations<br />

In the previous sections, we used the assignment operator := to assign a value to a variable. Although<br />

for most of the graphics that we will present in later chapters, an assignment is appropriate,<br />

specifying a graphic in terms of expressions is not only more flexible, but also more in the spirit<br />

of the designers of METAFONT and METAPOST.<br />

The METAFONT book and METAPOST manual provide lots of examples, some of which involve math<br />

that we don't consider to belong to everyones repertoire. But, even for non mathematicians using<br />

expressions can be a rewarding challenge.<br />

The next introduction to linear equations is based on my first experiences with METAPOST and<br />

involves a mathematical challenge posed by a friend. I quickly ascertained that a graphical proof<br />

was far more easy than some proof with a lot of sin(this) and cos(that) and long forgotten formulas.<br />

I was expected to prove that the lines connecting the centers of four squares drawn upon the four<br />

sides of a quadrilateral were perpendicular (see figure 1.2).<br />

Welcome to MetaPost Linear equations

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

Saved successfully!

Ooh no, something went wrong!