summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/metapost/base/source-tutorial/draw.tex
diff options
context:
space:
mode:
authorTaco Hoekwater <taco@elvenkind.com>2009-05-27 14:02:03 +0000
committerTaco Hoekwater <taco@elvenkind.com>2009-05-27 14:02:03 +0000
commit4634529c1714116c9bdb794a60ce12a9f20ae463 (patch)
tree6b29683be6c6c2a35d06589bb06825df2be66ba1 /Master/texmf-dist/doc/metapost/base/source-tutorial/draw.tex
parent30d91185abefb047f73a3cf6f7c69b13fa2391f6 (diff)
second part of the new metapost documentation:
* rename source to source-manual * add source-tutorial * update the pdfs and index.html * remove superfluous Makefile git-svn-id: svn://tug.org/texlive/trunk@13496 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/metapost/base/source-tutorial/draw.tex')
-rw-r--r--Master/texmf-dist/doc/metapost/base/source-tutorial/draw.tex46
1 files changed, 46 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/metapost/base/source-tutorial/draw.tex b/Master/texmf-dist/doc/metapost/base/source-tutorial/draw.tex
new file mode 100644
index 00000000000..9ed9b3c1ed0
--- /dev/null
+++ b/Master/texmf-dist/doc/metapost/base/source-tutorial/draw.tex
@@ -0,0 +1,46 @@
+\subsection{The \texttt{draw} command}
+
+The most common command in \MP{} is the |draw| command. This command is
+used to draw paths or pictures. In order to draw a path from
+|z1:=(0,0)| to |z2:=(54,18)| to |z3:=(72,72)|, we should first decide
+how we want the path to look. For example, if we want these points to
+simply be connected by line segments, then we use
+
+\begin{lstlisting}[style=MP]
+draw z1--z2--z3;
+\end{lstlisting}
+
+However, if we want a smooth path between these points, we use
+
+\begin{lstlisting}[style=MP]
+draw z1..z2..z3;
+\end{lstlisting}
+
+In order to specify the direction of the path at the points, we use the
+|dir| operator. In \autoref{fig:draw1} we see that the smooth path is
+horizontal at |z1|, a 45\textdegree\ angle at |z2|, and vertical at
+|z3|. These constraints on the B\'{e}zier curve are imposed by
+
+\begin{lstlisting}[style=MP]
+draw z1{right}..z2{dir 45}..{up}z3;
+\end{lstlisting}
+
+\begin{figure}
+ \begin{withattachment}{draw.mp}
+ \centering
+ \includegraphics{draw-1.mps}
+ \end{withattachment}
+ \caption{\texttt{draw} examples}
+ \label{fig:draw1}
+\end{figure}
+
+Notice that |z2{dir 45}| forces the \textit{outgoing} direction at |z2|
+to be 45\textdegree. This implies an \textit{incoming} direction at
+|z2| of 45\textdegree. In order to require different incoming and
+outgoing directions, we would use
+
+\begin{lstlisting}[style=MP]
+draw z1{right}..{dir |$\theta_i$|}z2{dir |$\theta_o$|}..{up}z3;
+\end{lstlisting}
+where $\theta_i$ and $\theta_o$ are the incoming and outgoing
+directions, respectively.