| 1 |
\section{Introduction} |
| 2 |
\label{sec:introduction} |
| 3 |
|
| 4 |
To accompany \TeX{}, Knuth developed \MF{} as a method of ``creating |
| 5 |
entire families of fonts from a set of dimensional parameters and |
| 6 |
outline descriptions''~\cite{beebe:mf}. Approximately ten years later, |
| 7 |
John Hobby began work on \MP{}\Dash ``a powerful graphics language based |
| 8 |
on Knuth's \MF, but with PostScript output and facilities for including |
| 9 |
typeset text''~\cite{hobby:user}. Although several packages (e.g., |
| 10 |
\PiC\TeX, \Xy-pic, and the native \LaTeX{} picture environment to name a |
| 11 |
few) are available for creating graphics within \TeX-based documents, |
| 12 |
they all rely on \TeX{}. Since \TeX{} was designed to typeset text, it |
| 13 |
seems natural that an external utility should be used to generate |
| 14 |
graphics instead. Furthermore, in the event that the graphics require |
| 15 |
typeset text, then the utility should use \TeX{} for this requirement. |
| 16 |
This premise is exactly the philosophy of \MP. |
| 17 |
|
| 18 |
Since \MP{} is a programming language, it accommodates data structures |
| 19 |
and flow control, and compilation of the \MP{} source code yields \EPS{} |
| 20 |
graphics. These features provide an elegant method for generating |
| 21 |
graphics. \autoref{fig:circles} illustrates how \MP{} can be used |
| 22 |
programatically. The figure is generated by rotating one of the circles |
| 23 |
multiple times to obtain the desired \textit{circular chain}.% |
| 24 |
\footnote{All graphics in this tutorial (except \autoref{fig:previewer}) |
| 25 |
are created with \MP{}, and the source code and any required external |
| 26 |
data files for each of these graphics are embedded as file attachments |
| 27 |
in the electronic \PDF{} version of the article. Attachments are |
| 28 |
indicated by a paper clip icon. |
| 29 |
|
| 30 |
\vspace{-\baselineskip} |
| 31 |
\noindent% |
| 32 |
\raisebox{0pt}[0pt][0pt]{% |
| 33 |
\makebox[0pt][r]{% |
| 34 |
\notextattachfile{\paperclip}% |
| 35 |
\hspace*{\marginparsep}% |
| 36 |
}% |
| 37 |
}% |
| 38 |
} |
| 39 |
|
| 40 |
\begin{figure} |
| 41 |
\begin{withattachment}{circles.mp} |
| 42 |
\centering |
| 43 |
\includegraphics{circles.mps} |
| 44 |
\end{withattachment} |
| 45 |
\caption{Rotated circles} |
| 46 |
\label{fig:circles} |
| 47 |
\end{figure} |
| 48 |
|
| 49 |
The programming language constructs of \MP{} also deliver a graceful |
| 50 |
mechanism for creating animations without having to manually create each |
| 51 |
frame of the animation. The primary advantage of \EPS{} is that it can |
| 52 |
be scaled to any resolution without a loss in quality. It can also be |
| 53 |
easily converted to raster formats, e.g.\ Portable Network Graphics |
| 54 |
(\PNG) and Joint Photographic Experts Group (\JPEG), et al., or other |
| 55 |
vector formats including Portable Document Format (\PDF) and Scalable |
| 56 |
Vector Graphics (\SVG), et al. |