% signal=squid

\startcomponent excursion-en-metapost

\enablemode[**en-us]

\project excursion

\startchapter[title=Graphical extension / \METAPOST]

\index[metapost]{\METAPOST}
\index{graphical features}

\startbuffer
\startreusableMPgraphic{origin}
  path pb; pb:=(5.5cm,0cm)..(10.5cm,0cm);
  path qb; qb:=(8cm,-1cm)..(8cm,2.5cm);
  pickup pencircle scaled 0.5mm;
  drawarrow pb;
  drawarrow qb;
  draw thelabel.rt(textext("\im{x}"),(10.6cm,0cm));
  draw thelabel.top(textext("\im{y}"),(8cm,2.6cm));
  path l; l:=(5.5cm,-0.5cm)..(10.5cm,2cm);
  pickup pencircle scaled 0.3mm;
  draw l withcolor blue ;
  pair A; A:=(6cm,-0.25cm);
  pair B; B:=(9.3cm,1.4cm);
  pair C; C:=(9.3cm,-0.25cm);
  pickup pencircle scaled 0.15cm;
  drawdot A; drawdot B; drawdot C;
  draw thelabel.lrt(textext
    ("\im{\scriptstyle P_1(x_1,y_1)}") ,A);
  draw thelabel.lrt(textext
    ("\im{\scriptstyle P_2(x_2,y_2)}") ,B);
  draw thelabel.bot(textext
    ("\im{\scriptstyle P(x_2,y_1)}"  ) ,C);
  path s; s:=A..(9.3cm,-0.25cm);
  draw s dashed (evenly scaled 1mm)
    withpen pencircle scaled 0.3mm;
  path t; t:=B..(9.3cm,-0.25cm);
  draw t dashed (evenly scaled 1mm)
    withpen pencircle scaled 0.3mm;
\stopreusableMPgraphic
\stopbuffer

\getbuffer

The graphical possibilities of \TEX||related macro packages are rather limited.
However, by using the graphical package \METAPOST\ of John Hobby a complete range
of graphical features has become available that may improve the look of your
documents.

\CONTEXT\ is closely linked to \METAPOST. You have direct access to this
graphical environment. Running a document containing \METAPOST\ code will
generate the figure on the fly.

E.g. The decorative elements of chapter headers and page numbers of this manual
are generated by \METAPOST.

\METAPOST\ is the base and many extensions were built for it. Due to these
extensions in the \CONTEXT\ environment the graphical environment is called
\METAFUN.

If you look carefully at these \METAPOST\ extensions you will notice a lot of
contextual adaptation (width and height dependent) and randomization. So you can
do things in your document that are not possible in other typesetting
applications.

A more practical example (for a mathematician at least) is drawn in \in {figure}
[fig:metapostexample]:

\startplacefigure
  [location=here,
   reference=fig:metapostexample,
   title={\METAPOST\ example.}]
  \reuseMPgraphic{origin}
\stopplacefigure

This example is taken from the mathematical text book \Emph{Algetrigulus} by
Philip Brown. All graphics in his book are made by means of \METAPOST.
\page[bigpreference]

This one is defined by:

\typebuffer

The usage and features of \METAPOST\ within \CONTEXT\ are described in the
extensive \goto {\Emph{\METAFUN\ manual}} [ url (manual:metafun) ].

\blank

There is another graphical system out in the \TEX\ world. Its name is
\Emph{TikZ}. \CONTEXT\ supports this software even though its development
completely takes place outside the \CONTEXT\ environment. For installation see
\goto{\Emph{\CONTEXTWIKI, Installing TikZ and pgfplot}} [ url (www:garden:tikz) ]
and \goto{\Emph{\CONTEXTWIKI, Drawing graphics and diagrams with TikZ}} [ url
(https://wiki.contextgarden.net/Graphics_and_media/Drawing_graphs_and_diagrams/TikZ)
]. TikZ's user manual is \goto{\Emph{TikZ \& PGF manual}} [ url (manual:tikz) ].

\stopchapter

\stopcomponent
