| 1 |
\subsection{The \texttt{draw} command} |
| 2 |
|
| 3 |
The most common command in \MP{} is the |draw| command. This command is |
| 4 |
used to draw paths or pictures. In order to draw a path from |
| 5 |
|z1:=(0,0)| to |z2:=(54,18)| to |z3:=(72,72)|, we should first decide |
| 6 |
how we want the path to look. For example, if we want these points to |
| 7 |
simply be connected by line segments, then we use |
| 8 |
|
| 9 |
\begin{lstlisting}[style=MP] |
| 10 |
draw z1--z2--z3; |
| 11 |
\end{lstlisting} |
| 12 |
|
| 13 |
However, if we want a smooth path between these points, we use |
| 14 |
|
| 15 |
\begin{lstlisting}[style=MP] |
| 16 |
draw z1..z2..z3; |
| 17 |
\end{lstlisting} |
| 18 |
|
| 19 |
In order to specify the direction of the path at the points, we use the |
| 20 |
|dir| operator. In \autoref{fig:draw1} we see that the smooth path is |
| 21 |
horizontal at |z1|, a 45\textdegree\ angle at |z2|, and vertical at |
| 22 |
|z3|. These constraints on the B\'{e}zier curve are imposed by |
| 23 |
|
| 24 |
\begin{lstlisting}[style=MP] |
| 25 |
draw z1{right}..z2{dir 45}..{up}z3; |
| 26 |
\end{lstlisting} |
| 27 |
|
| 28 |
\begin{figure} |
| 29 |
\begin{withattachment}{draw.mp} |
| 30 |
\centering |
| 31 |
\includegraphics{draw-1.mps} |
| 32 |
\end{withattachment} |
| 33 |
\caption{\texttt{draw} examples} |
| 34 |
\label{fig:draw1} |
| 35 |
\end{figure} |
| 36 |
|
| 37 |
Notice that |z2{dir 45}| forces the \textit{outgoing} direction at |z2| |
| 38 |
to be 45\textdegree. This implies an \textit{incoming} direction at |
| 39 |
|z2| of 45\textdegree. In order to require different incoming and |
| 40 |
outgoing directions, we would use |
| 41 |
|
| 42 |
\begin{lstlisting}[style=MP] |
| 43 |
draw z1{right}..{dir |$\theta_i$|}z2{dir |$\theta_o$|}..{up}z3; |
| 44 |
\end{lstlisting} |
| 45 |
where $\theta_i$ and $\theta_o$ are the incoming and outgoing |
| 46 |
directions, respectively. |