% output=pdftex engine=pdftex language=uk
%
% copyright=pragma-ade readme=readme.pdf licence=cc-by-nc-sa

\startcomponent mfun-016

\environment mfun-000

\chapter {This document}

\startintro

This document is produced in \CONTEXT\ and can serve as an
example of how to integrate \METAPOST\ graphics into \TEX. In
this appendix we will discuss some details of producing this
document.

\stopintro

We did not use any special tricks, so most of the examples
you have seen, were coded just as shown. We use buffers to
ensure that the code used to produce the accompanying
graphic is identical to the typeset code in the document.
Here is an example.

\starttyping
\startbuffer[dummy]
draw fullcircle
  xscaled 3cm yscaled 2cm
  rotatedaround(origin,30)
  withcolor .625red ;
\stopbuffer
\stoptyping

Instead of using \type {\getbuffer}, we used the following
command:

\starttyping
\startlinecorrection[blank]
\processMPbuffer[dummy]
\stoplinecorrection
\stoptyping

The line correction commands take care of proper spacing
around the graphic. If you want to process more buffers at
once, you can pass their names as a comma separated list.

Alternatively, we could have said:

\starttyping
\startuseMPgraphic{dummy}
  draw fullcircle
    xscaled 3cm yscaled 2cm
    rotatedaround(origin,30)
    withcolor .625red ;
\stopuseMPgraphic
\stoptyping

When including this graphic, we again take care of spacing.

\starttyping
\startlinecorrection[blank]
\useMPgraphic{dummy}
\stoplinecorrection
\stoptyping

Because the number of graphics is large, we process this
document using the \type {--automp} directive (using
\TEXEXEC).

The document style is not that complicated. The main
complication in such a document is to make sure that
\METAPOST\ is operating under the same font regime. As
document font we use the URW Palatino for the running text
combined with Computer Modern Typewriter.

Because this document is available as paper and screen
document, some large graphics are scaled down in the screen
version.

We don't use any special tricks in typesetting this
document, but when we added the section about transparency,
a dirty trick was needed in a few cases order to get the
described results. Because the screen document has a gray
backgrounds, exclusive transparencies come out \quote
{wrong}. In the function drawing example we use the
following trick to get a black background behind the
graphics only. We have a buffer that contains a few lines
of code:

% buffer only available in screen mode

\starttyping
picture savedpicture ;
savedpicture := currentpicture ;
currentpicture := nullpicture ;
draw savedpicture withcolor black ;
draw savedpicture ;
\stoptyping

Since we use buffers for the graphics as well, we can now
process an buffer with name \type {example} as follows:

\starttyping
\processbuffer[example,wipe]
\stoptyping

This means that the example code is included two times.
After it is processed, we recolor the currentpicture black,
and after that we add the original picture once again.

\stopcomponent
