23.10.2014 Views

mfpic-doc.pdf.

mfpic-doc.pdf.

mfpic-doc.pdf.

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.

4.12 FOR ADVANCED USERS. 68<br />

Using \regpolygon{〈num〉}{X}{...}{...} causes a pair array named X to be defined having<br />

〈num〉 elements (and the additional pair X0 for the center). This is in addition to creating the actual<br />

figure. The variable X alone becomes a numeric equated to 〈num〉.<br />

Using \piechart (or \mfppiechart) causes the following arrays to become defined (or redefined):<br />

– piewedge, a path array describing the wedges of the chart. To access piewedge[1], for example,<br />

one could use \mfobj{piewedge[1]}. This is almost exactly the same as the MFPIC<br />

command \piewdge{1} without optional arguments.<br />

– pieangle, a numeric array, gives the starting angles of the wedges.<br />

– piedirection, a pair array, gives the unit vectors pointing from the center of the piechart<br />

through middles of the wedges. For example, if \pieangle1 is 0 and pieangle2 is 90 degrees,<br />

then piedirection1 is (cos45,sin45), the unit vector whose angle is 45 degrees.<br />

Using \barchart (or \mfpbarchart or any of its aliases) causes the following arrays to become<br />

defined (or redefined). The exact meaning depends on whether bars are horizontal or vertical. The<br />

following describes horizontal bars; exchange the roles of x and y if they are vertical (also change<br />

‘right’ to ‘top’, etc.):<br />

– barstart, a numeric array, gives the position on the y-axis of the leading edge of the bars.<br />

– barbegin, numeric, gives the x-coordinate of the leftmost end of the bars.<br />

– barend, numeric, gives the x-coordinate of the rightmost end of the bars.<br />

– chartbar, a path array, gives the actual bars. For example, chartbar2 is the rectangle with<br />

opposite corners (barbegin2,barstart2) and (barend2,barstart2+barwd), where the<br />

numeric variable barwd is the thickness of the bar (which is a height for horizontal bars).<br />

– barlength, the same as barend. This is for backward compatibility; the name was chosen at<br />

a time when all the bars had one side on an axis.<br />

4.12.5 MISCELANEOUS PAIR EXPRESSIONS<br />

A useful METAFONT operator that produces points is the intermediation operator, whose syntax is<br />

(〈num〉)[〈p 1 〉,〈p 2 〉]<br />

That is, a number or numeric expression in parentheses followed by literal brackets (this is not<br />

an optional argument) containing two points or pair expressions separated by a comma. It returns<br />

an intermediate point on the line through 〈p 1 〉 and 〈p 2 〉. The formula for the returned value is p 1 +<br />

〈num〉(p 2 − p 1 ). The midpoint is obtained with 〈num〉 = .5. If the 〈num〉 is a pure number, the<br />

parentheses can be omitted, but they are required if it is any other numeric expression. Values of<br />

〈num〉 larger than 1 or less than zero produce points on the line that lie outside the segment from p 1<br />

to p 2 . This operator can also be applied to numbers or (in METAPOST) to colors (of the same type).<br />

So that (2/3)[3,6] = 5 and .7[green,blue] = (0,.3,.7). See section 4.3 for a description<br />

of colors in METAPOST and METAFONT.<br />

pathpoint(〈frac〉,〈name〉)<br />

This is another useful METAFONT command. It requires a number, 〈frac〉, and the name of a<br />

previously defined METAFONT path variable. (Defined, for example, using \store; see subsection<br />

4.10.2). It returns the point on the path that is approximately that fraction of the path’s length<br />

from the start of the path. For example to draw a line from (0,0) to the midpoint of an arc, do the<br />

following:<br />

\store{myarc}\draw\arc{(1,0),(0,2),90}<br />

\polyline{(0,0), pathpoint(.5,myarc)}

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

Saved successfully!

Ooh no, something went wrong!