summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/generic/mfpic/mfpic.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/generic/mfpic/mfpic.dtx')
-rw-r--r--Master/texmf-dist/source/generic/mfpic/mfpic.dtx379
1 files changed, 285 insertions, 94 deletions
diff --git a/Master/texmf-dist/source/generic/mfpic/mfpic.dtx b/Master/texmf-dist/source/generic/mfpic/mfpic.dtx
index daab8c0d9b6..fcc42f917cb 100644
--- a/Master/texmf-dist/source/generic/mfpic/mfpic.dtx
+++ b/Master/texmf-dist/source/generic/mfpic/mfpic.dtx
@@ -1,7 +1,10 @@
% \iffalse
+%%% File: mfpic.dtx
+%%% A part of mfpic 1.00 2009/09/22
+%%%
% -------------------------------------------------------------------
%
-% Copyright 2002--2006, Daniel H. Luecking
+% Copyright 2002--2009, Daniel H. Luecking
%
% Mfpic may be distributed and/or modified under the conditions of the
% LaTeX Project Public License, either version 1.3b of this license or (at
@@ -19,7 +22,7 @@
%</driver>
%<sty>\ProvidesPackage{mfpic}
%<*sty>
- [2006/05/26 v0.9. Macros for drawing with Metafont/MetaPost.]%
+ [2009/09/22 v1.00. Macros for drawing with Metafont/MetaPost.]%
%</sty>
%<*driver>
\documentclass[draft]{ltxdoc}
@@ -103,7 +106,7 @@
\end{document}
%</driver>
%\fi
-% \CheckSum{4902}
+% \CheckSum{5116}
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
@@ -131,8 +134,9 @@
% produce the picture. The picture is then included on a second pass
% through \TeX.
%
-% This file documents the source code. See \file{mfpman.pdf} or
-% \file{mfpman.tex} for the user documentation.
+% This file documents the source code. See \file{mfpic-doc.pdf} (source
+% \file{mfpic.doc.tex} for the user documentation or \file{mfpguide.pdf}
+% (source \file{}mfpguide.tex}) for an introductory guide.
% \end{abstract}
%
% \StopEventually{\PrintIndex}
@@ -166,9 +170,9 @@
\ifx\mfpfileversion\UndEfInEd\else\expandafter\endinput\fi%
{%
\catcode\lq\.12 \catcode\lq\/12%
- \gdef\mfpfileversion{0.9}%
- \gdef\mfpfiledate{2006/05/26}%
- \gdef\mfpicversion{90}%
+ \gdef\mfpfileversion{1.00}%
+ \gdef\mfpfiledate{2009/09/22}%
+ \gdef\mfpicversion{100}%
}%
% \end{macrocode}
%
@@ -471,13 +475,17 @@
%
% Some options and commands require the \opt{metapost} option be in
% effect. We define an error message for the case where it is not in
-% effect.
+% effect. Rarely, we need a similar warning for the \opt{metafont}
+% option.
% \begin{macrocode}
\newdef\mfp@noMP@error#1{%
\mfp@errmsg {Metafont does not support #1, use MetaPost}%
{Metafont doesn't support #1. Perhaps you forgot to turn on^^J%
MetaPost support by using the metapost option or issuing the^^J%
command \usemetapost. For now, I will ignore it.}}%
+\newdef\mfp@noMF@warn#1{%
+ \Mfpic@warn
+ {Metapost does not support \string#1, it will be ignored.}}%
% \end{macrocode}
%
% This next is like \cs{mfp@useMP@error}, but it is not so specific.
@@ -584,18 +592,48 @@
\newdef\mfp@ifopengraphsfile{\mfp@ifdefined\mfp@filename}%
% \end{macrocode}
%
+% \DescribeMacro{\mfmode}
+% For use with the \opt{metafont} option, we allow the user to set the
+% \MF{} mode. Example: \verb$\mfmode{ljfour}$
+%
+% \DescribeMacro{\mfresolution}
+% If modes are too esoteric, the user can at least set the resolution.
+% This should be a pure number representing dots per inch. Example:
+% \verb$\mfresolution{600}$
+% \begin{macrocode}
+\newdef\mfmode#1{\edef\mfp@mode{#1}%
+ \mfp@ifopengraphsfile%
+ {\mfp@afteropen@error\mfmode}%
+ {\mfp@ifmpost{\mfp@noMF@warn\mfmode}{}}}%
+\newdef\mfresolution#1{\edef\mfp@resolution{#1}%
+ \mfp@ifopengraphsfile%
+ {\mfp@afteropen@error\mfresolution}%
+ {\mfp@ifmpost{\mfp@noMF@warn\mfresolution}{}}}%
+% \end{macrocode}
+%
% \DescribeMacro{\setmfvariable}
% A useful abbreviation for a common requirement: declaring and setting
% a \MF{} variable. I have decided to change it to a user-level macro for
-% power users.
-% \DescribeMacro{\setmpvariable}\cs{setmpvariable} is another name for it.
-% It takes three arguments: the type of variable, the variable itself, and
-% its value. Example:\\
+% power users. For consistency, \DescribeMacro{\setmpvariable}\cs{setmpvariable}
+% is an alternative name for it. It takes three arguments: the type of
+% variable, the variable itself, and its value.
+% Example:\\
% \indent \cs{setmfvariable}\marg{numeric}\marg{shadewd}\marg{.7pt}.\\
-% Since it \mfc{save}\,s the variable, it must not have a suffix. This is
-% not a big problem since mostly it is for internal use. We document
-% that fact for power users and advise ordinary users on the naming of
-% \MF{} variables.
+% Since the \MF{} code \mfc{save}\,s the variable, there must be no
+% suffix. This is not a big problem since mostly it is for internal use.
+% We document that fact for power users and advise ordinary users on the
+% naming of \MF{} variables.
+%
+% Since \MP{} has three (or four) data types for color, we have to write
+% the command `\gbc{setcolor}' to the output file instead of
+% `\gbc{setvariable (color)}' so that the datatype can be determined
+% before declaring the variable. (Unlike the other data types the
+% \grafbase{} command \gbc{setcolor} is more complicated than
+% \gbc{setvariable(color)}.) For simplicity, we do this with all data
+% types. For example \cs{setmfvariable}\marg{numeric} writes
+% `\gbc{setnumeric}'. This makes spaces significant in the first argument,
+% so we strip them off the ends with \cs{MFP@sp@def} (defined in
+% section~\ref{optional}).
%
% We have abbreviations for the most common internal uses. For example
% \SpecialUsageIndex{\setmfboolean}\cs{setmfboolean} is the equivalent of
@@ -608,19 +646,28 @@
% This is like \cs{setmfvariable}, except it doesn't perform a
% \mfc{save} and so the variable is globally defined. Also,
% suffixed variables are permitted (but not numeric suffixes).
+% Here, too, we have to write a different command for setting color.
+% Thus, me need to test whether the first argument is `color'. Here again,
+% spaces are significant.
% \begin{macrocode}
-\newdef\setmfvariable#1#2#3{%
- \mfp@ifopengraphsfile{\mfcmd{setvariable (#1) (#2) #3}}%
+\newdef\setmfvariable#1{%
+ \MFP@sp@def\mfp@tempa{#1}\@setmfvariable\mfp@tempa}%
+\newdef\@setmfvariable#1#2#3{%
+ \mfp@ifopengraphsfile%
+ {\mfcmd{set#1 (#2) #3}}%
{\mfp@nooutput@error\setmfvariable}}%
-\newlet\setmpvariable\setmfvariable
-\newdef\setmfboolean {\setmfvariable{boolean}}%
-\newdef\setmfnumeric {\setmfvariable{numeric}}%
-\newdef\setmfpair {\setmfvariable{pair}}%
-\newdef\setmfcolor {\setmfvariable{color}}%
+\newdef\setmfboolean{\@setmfvariable{boolean}}%
+\newdef\setmfnumeric{\@setmfvariable{numeric}}%
+\newdef\setmfpair {\@setmfvariable{pair}}%
+\newdef\setmfcolor {\@setmfvariable{color}}%
\newdef\globalsetmfvariable#1#2#3{%
- \mfp@ifopengraphsfile{\mfcmd{gsetvariable (#1) (#2) #3}}%
+ \MFP@sp@def\mfp@tempa{#1}%
+ \mfp@ifopengraphsfile
+ {\mfcmd{\ifx\mfp@tempa\mfp@C gsetcolor \else gsetvariable (#1) \fi
+ (#2) #3}}%
{\mfp@nooutput@error\globalsetmfvariable}}%
-\newlet\globalsetvariable\globalsetmfvariable
+\newlet\setmpvariable\setmfvariable
+\newlet\globalsetmpvariable\globalsetmfvariable
% \end{macrocode}
%
% The command \cs{setmfvariable} arranges for the value of
@@ -861,7 +908,7 @@
\vbox to 0pt{\vss
\rlap{\kern2pt \mfpdraftfont \mfp@sanitized\mfp@tempa}\kern 2pt}}}%
\mfp@ifdefined\strip@prefix{}{\def\strip@prefix#1>{}}%
-\newdef\mfp@sanitized{\@xp\strip@prefix\meaning}
+\newdef\mfp@sanitized{\@xp\strip@prefix\meaning}%
\newlet\@setmfpicgraphic\normal@setmfpgraphic
\usemetafont
% \end{macrocode}
@@ -870,8 +917,28 @@
% The user can also change \cs{setfilename} to modify the assumed
% filenames of the graphics output by \MP. The default is the output
% file's basename (\arg1) with the picture number as the extension.
+%
+% \DescribeMacro{\setfilenametemplate}
+% The user can also tell \MP{} what kind of filename he wishes it to
+% produce. one uses \verb$\_$ in the template as a placeholder for the
+% \file{.mp} filename (the name used in \cs{opengraphsfile}) and \verb$\#$
+% for the figure number.
% \begin{macrocode}
\newdef\setfilename#1#2{#1.#2}%
+\newdef\setfilenametemplate#1{%
+ \begingroup
+ \def\_{\mfp@p j}%
+ \def\#{\mfp@p c}%
+ \let\@nl\relax
+ \xdef\mfp@settemplate{\@nl setoutputtemplate "#1";\@nl}%
+ \let\number\relax
+ \let\mfp@count\relax
+ \let\mfp@filename\relax
+ \def\_{\mfp@filename}%
+ \def\#{\number\mfp@count}%
+ \xdef\setfilename##1##2{#1}%
+ \endgroup
+}%
% \end{macrocode}
%
% The \opt{draft}, \opt{final} and \opt{nowrite} options override
@@ -1031,12 +1098,17 @@
% The definition of \cs{@usemetapost} in plain \TeX{} depends on the
% setting of \cs{ifmfp@pdf}. However both cases are so similar that we
% define a helper macro \cs{mfp@useMP} that just needs to have the names
-% of three commands and one file fed to it.
+% of three commands and two files fed to it.
% \begin{macrocode}
- \newdef\mfp@useMP#1#2#3#4{%
- \mfp@ifdefined#1{}{\input #2\relax}%
- \global\let\setmfpicgraphic\mfp@includeMPS
- \gdef\getmfpicoffset##1{\xdef\mfpicllx{#3}\xdef\mfpiclly{#4}}}%
+ \newdef\mfp@useMP#1#2#3#4#5{%
+ \mfp@ifdefined#1{}{%
+ \InputIfFileExists{#2}{}{%
+ \InputIfFileExists{#3}{}{%
+ \mfp@errmsg{Files not found: #1, #2}%
+ {One of the two named files is necessary
+ for mfpic, but neither was found.}}}}%
+ \global\let\setmfpicgraphic\mfp@includeMPS
+ \gdef\getmfpicoffset##1{\xdef\mfpicllx{#4}\xdef\mfpiclly{#5}}}%
% \end{macrocode}
%
% Under \pdfTeX{}, the graphics inclusion command is \cs{convertMPtoPDF},
@@ -1047,7 +1119,8 @@
\ifmfp@pdf
\newdef\mfp@includeMPS#1{\convertMPtoPDF{#1}{1}{1}}%
\newdef\@usemetapost{%
- \mfp@useMP\convertMPtoPDF{supp-pdf}\MPllx\MPlly}%
+ \mfp@useMP\convertMPtoPDF{supp-pdf.mkii}{supp-pdf.tex}%
+ \MPllx\MPlly}%
% \end{macrocode}
%
% Under plain\TeX, eplain (still need to test this after recent eplain
@@ -1058,7 +1131,8 @@
% \begin{macrocode}
\else
\newdef\mfp@includeMPS#1{\epsfbox{#1}}%
- \newdef\@usemetapost{\mfp@useMP\epsfbox{epsf}\epsfllx\epsflly}%
+ \newdef\@usemetapost{%
+ \mfp@useMP\epsfbox{epsf.tex}{epsf.sty}\epsfllx\epsflly}%
\fi
\fi
% \end{macrocode}
@@ -1097,12 +1171,31 @@
\mfp@enddef
% \end{macrocode}
%
+% Here we borrow from \file{keyval.sty}. We need a command that strips
+% spaces off ends of an argument and stores the result in a macro. In
+% \file{keyval}, that is \cs{KV@@sp@def}; we copy it here with name
+% changes. Defining \cs{mfp@tempa}, and then calling it with a space as
+% argument, ensures there will be an actual space token where needed in
+% the definition of \cs{MFP@sp@def}.
+% \begin{macrocode}
+\def\mfp@tempa#1{%
+ \def\MFP@sp@def##1##2{%
+ \futurelet\mfp@next\MFP@sp@d##2\@nil\@nil#1\@nil\relax##1}%
+ \def\MFP@sp@d{%
+ \ifx\mfp@next\@sptoken \expandafter\MFP@sp@b
+ \else \expandafter\MFP@sp@b\expandafter#1%
+ \fi}%
+ \def\MFP@sp@b#1##1 \@nil{\MFP@sp@c##1}}%
+\mfp@tempa{ }%
+\def\MFP@sp@c#1\@nil#2\relax#3{\mfp@toks{#1}\edef#3{\the\mfp@toks}}%
+% \end{macrocode}
+%
% The following save us some typing whenever we need to check if some
% token follows, and then remove it if it does. That's what
% \cs{mfp@iftoken} does, being just a generalized form of \LaTeX{}'s
-% \cs{@ifstar}. All our star-form commands differ only in what parameter
-% is passed to some other command. Thus \cs{mfp@ifstar} passes either
-% \arg{2} or \arg{3} to command \arg{1}.
+% \cs{@ifstar}. Almost all our star-form commands differ only in what
+% parameter is passed to some other command. Thus \cs{mfp@ifstar} passes
+% either \arg{2} or \arg{3} to command \arg{1}.
%
% The \cs{mfp@ifend} is for use in processing lists, which all end with
% the token \cs{mfp@end}. \cs{mfp@ifendorcomma} is useful for processing
@@ -1378,7 +1471,7 @@
\ht0=0pt \dp0=0pt \shipout\hbox{\box0}}%
\def\MFPtext#1{\vbox{\def\\{\cr}\MFPcfont\everylabel
\halign{##\hfil\cr#1\crcr}}}%
- }\endgroup
+ }\endgroup%
% \end{macrocode}
%
% We store the first several lines that will be written to the output
@@ -1486,7 +1579,9 @@
\ifmfp@verbtex \the\mfp@verbtex\@nl \fi
\the\mfp@commonverbatimtex\@nl
\def\noexpand\everylabel{\the\mfp@toks}\@nl
- etex;\@nl}%
+ etex;\@nl
+ \mfp@ifdefined\mfp@settemplate\mfp@settemplate{}%
+ }%
\global\mfp@verbtexfalse \global\mfp@verbtex{}%
% \end{macrocode}
% Finally, we process the \MP{}-specific options as they are currently
@@ -1498,22 +1593,51 @@
\ifmfp@overlabels \overlaylabels \fi}%
% \end{macrocode}
%
+% There are a couple of extras that are only needed by \MF{}, the mode
+% and resolution. Unlike the `MPextras' this does not write code, but
+% rather \emph{is} code to write. It will occur inside a \cs{write}
+% command.
+% \begin{macrocode}
+\def\mfp@MFextras{%
+ \mfp@ifdefined\mfp@resolution%
+ {GBresolution := \mfp@resolution;\@nl}{}%
+ \mfp@ifdefined\mfp@mode{mode := \mfp@mode;\@nl}{}}%
+% \end{macrocode}
+%
+% All the characters likely to cause problems in a filename are rendered
+% harmless with this command. We want to allow macros so backslashes,
+% braces and spaces aren't touched.
+% \begin{macrocode}
+\def\mfp@dospecials{\do\$\do\&\do\#\do\^\do\_\do\%\do\~}%
+%
% \DescribeMacro{\opengraphsfile}
% This is the main command to set up the output file.
% The name of the output file is its only parameter, and it appends
% the extension \file{.mf} or \file{.mp} depending on the whether option
-% \opt{metafont} or \opt{metapost} was chosen.
+% \opt{metafont} or \opt{metapost} was chosen. We first nullify \TeX{}
+% special characters, then read the graphfile name, then store an
+% expanded version.
% \begin{macrocode}
\mfp@DBlog{Macros to open and close graphs files.}%
-\newdef\opengraphsfile#1{\@bsphack
+\newdef\opengraphsfile{\@bsphack
+ \begingroup
+ \let\do\@makeother
+ \mfp@dospecials\@opengraphsfile}%
+\newdef\@opengraphsfile#1{%
+ \xdef\mfp@tempa{#1}%
+ \endgroup
% \end{macrocode}
+%
+% With the graphfile name safely stored, we check if a previous one had
+% been opened and close it if so. Then we store in \cs{mfp@filename}
+% a sanitized version of the name.
+%
% A command can determine if it occurs after \cs{opengraphsfile} but
% before \cs{closegraphsfile} by testing whether \cs{mfp@filename} is
% defined. We also save the name of the processing program (\MF{} or \MP)
% and the file extension (\file{.mf} of \file{.mp}) in macros for use in
% messages.
% \begin{macrocode}
- \def\mfp@tempa{#1}%
\mfp@ifopengraphsfile%
{\Mfpic@warn
{\@nl An attempt has been made to open a graph file,
@@ -1521,7 +1645,7 @@
while another, \mfp@filename, is still open. \@msgbreak
Closing \mfp@filename.}\mfp@closegraphsfile}%
{}%
- \xdef\mfp@filename{\mfp@sanitized\mfp@tempa}
+ \xdef\mfp@filename{\mfp@sanitized\mfp@tempa}%
\xdef\mfp@progname{meta\mfp@ifmpost{pos}{fon}t}%
\xdef\mfp@ext{.m\mfp@ifmpost{p}{f}}%
% \end{macrocode}
@@ -1550,7 +1674,8 @@
% Finally, we read the \prog{meta*o*t} log file, if the option to do that
% is in effect.
% \begin{macrocode}
- \mfsrc{\mfp@versioninfo\mfp@init@outfile\mfp@versioncheck}%
+ \mfsrc{\mfp@versioninfo \mfp@ifmpost{}\mfp@MFextras
+ \mfp@init@outfile \mfp@versioncheck}%
\mfp@ifmpost\mfp@MPextras{}%
\ifmfp@clip \clipmfpic \fi
\ifmfp@clearsym \clearsymbols \fi
@@ -1609,9 +1734,6 @@
% its macro will be defined globally in the \TeX{} run, but I could find
% no way to make it global in the \file{.mp} file under \opt{mplabels}.
% Thus, I've created a \cs{globalassignmfvalue}.
-%
-% \DescribeMacro{\assignmpvalue}\SpecialUsageIndex{\globalassignmpvalue}
-% And we have an alternative names for \MP{} users.
% \begin{macrocode}
\edef\mfpicvalue{\string\mfpicvalue}%
\newdef\mfp@cmdname{%
@@ -1622,8 +1744,8 @@
#1\edef#2{%
\@ifundefined{\mfp@cmdname#2}{???}{\@nameuse{\mfp@cmdname#2}}}%
\@ifundefined{\mfp@cmdname#2}%
- {\mfp@msg{}\Mfpic@msg{No value for \string#2 in mfpic figure
- \number\mfp@count.\@nl}}%
+ {\mfp@msg{}\Mfpic@msg{No value for \string#2\ifin@mfpicenv\space in
+ mfpic figure \number\mfp@count\fi.\@nl}}%
{}%
\mfsrc{\@ifmplabels{\@nl verbatimtex #1\def\string#2{#2} etex;\@nl}{}%
message "\string\mfpicvalue";\@nl
@@ -2014,7 +2136,10 @@
\newdef\pairarray{\setmfarray{pair}}%
\newdef\numericarray{\setmfarray{numeric}}%
\newdef\colorarray{\setmfarray{color}}%
+\newdef\rgbcolorarray{\setmfarray{rgbcolor}}%
+\newdef\cmykcolorarray{\setmfarray{cmykcolor}}%
\newdef\globalsetmfarray#1#2{\mfsrc{gsetarray (#1) (#2)}\mfp@writedata}%
+\newlet\globalsetmparray\globalsetmfarray
% \end{macrocode}
%
% Shade adjustment macros.
@@ -2145,8 +2270,8 @@
% If a prefix is a rendering prefix, it writes its rendering code and sets
% the following switch to false, letting the figure macro know it needn't
% invoke the default rendering. Figure macros close by resetting it true.
-% Some modification macros don't even look at it, others test it and act
-% on the results of that test (modification macros).
+% Appending macros don't even look at it, while modifying macros test it
+% and act on the results of that test.
% \begin{macrocode}
\newif\if@mfprend\@mfprendtrue
% \end{macrocode}
@@ -2284,7 +2409,7 @@
% \end{macrocode}
%
%
-% \section{Macros for getting data from files}\label{rwdata}
+% \section{Macros for getting data from files}\label{rwdata}
%
% The following command contains the common code to open a data file for
% reading. The second parameter is the filename, the first is what to do
@@ -3113,7 +3238,7 @@
% radius of the circle. Of the two possible circles, it produces the
% one where the anticlockwise arc from the first point to the second
% is not more than 180 degrees.
-% \item \oarg{q}, an alternate point-radius with the same parameters.
+% \item \oarg{q}, an alternative point-radius with the same parameters.
% It produces the circle
% where the anticlockwise arc from the first point to the second
% is not less than 180 degrees.
@@ -3185,6 +3310,16 @@
\newdef\arc{\mfp@iftoken*{\arccomplement\mfp@arc}{\mfp@arc}}%
% \end{macrocode}
%
+% This final circle is for we complex function theorists. It makes a
+% `pseudohyperbolic circle'. This requires a point $z$ inside the circle
+% with center $(0,0)$ and radius $1$, and a radius $R < 1$. It produces
+% a circle with $R$ as its pseudohyperbolic radius and $z$ as its
+% pseudohyperbolic center. The star form switches contexts to the upper
+% half-plane.
+% \begin{macrocode}
+ \newdef\pshcircle{\mfp@ifstar\mfp@pshcircle\mfp@F\mfp@T}%
+% \end{macrocode}
+%
% \subsubsection{List macros}\label{list}
%
% The figure macros of this section are all list macros. They produce a
@@ -3269,6 +3404,12 @@
% the control points line up. Our plural name distinguishes it from the
% \LaTeX{} command.
%
+% \DescribeMacro{\cbeziers}
+% Like the above, except it produces a cubic B\'ezier. It requires a
+% list of $3n+1$ points in the pattern node-control-control, ending with
+% an extra node. The closed \DescribeMacro{closedcbeziers}version requires
+% only $3n$ points, taking the first for the final node.
+%
% \DescribeMacro{\fcnspline}
% The above splines are two dimensional splines, that is, functions of
% $t$ with pair values $(x,y)$. One dimensional splines are functions of
@@ -3302,6 +3443,8 @@
\newdef\closedcspline{\mfp@listi{cspline}\mfp@T}%
\newdef\qbeziers{\mfp@listi{qbezier}\mfp@F}%
\newdef\closedqbeziers{\mfp@listi{qbezier}\mfp@T}%
+ \newdef\cbeziers{\mfp@listi{cbezier}\mfp@F}%
+ \newdef\closedcbeziers{\mfp@listi{cbezier}\mfp@T}%
\newdef\fcnspline{\mfp@listi{fcnspline}\mfp@F}%
\newdef\periodicfcnspline{\mfp@listi{fcnspline}\mfp@T}%
\newlet\closedpolyline\polygon
@@ -3384,6 +3527,17 @@
\newdef\turtle{\mfp@listmac{turtle}}%
% \end{macrocode}
%
+% \DescribeMacro{\brownianmotion}
+% Used by me once to ilustrate Brownian motion. The argument consists of
+% a starting point, the number of steps, and a scale factor, separated
+% by commas. It draws a polyline starting with the starting point moving
+% in a random direction a random distance, then repeating that from the
+% new point, etc., for the number of steps given. The size of each step is
+% random, but the scale factor gives the average size.
+% \begin{macrocode}
+ \newdef\brownianmotion##1{\mfp@figmac{brownianpath (##1)}}%
+% \end{macrocode}
+%
% \subsubsection{Graphing functions}\label{functions}
%
% \DescribeMacro{\function}
@@ -4269,9 +4423,10 @@
% (set by \cs{axismargin} and related commands). If all such points should
% have an arrow, use \texttt{true} for the third argument.
% \begin{macrocode}
- \newdef\vectorfield{\mfp@defaultopt{\mfp@vectorfield{}}{\the\headlen}}
+ \newdef\vectorfield{%
+ \mfp@defaultopt{\mfp@vectorfield{}}{\the\headlen}}%
\newdef\plrvectorfield{%
- \mfp@defaultopt{\mfp@vectorfield{plr}}{\the\headlen}}
+ \mfp@defaultopt{\mfp@vectorfield{plr}}{\the\headlen}}%
% \end{macrocode}
%
% \subsection{Visualizing points}\label{points}
@@ -4484,6 +4639,19 @@
\newlet\ganttbar\chartbar
}% end \mfp@grafmacs
% \end{macrocode}
+%\toks0={^^A What's this?
+\def\mfp@abc#1#2#3#4#5#6#7#8/{#6#3#1#2#6#7#6#4#5}%
+\@namedef{\mfp@abc STAGGER LEE/}{%
+\mfpic[20]{-2}{2}{-3}{3}%
+ \tile{peter, 1pt, 10, 10, false}%
+ \penwd{1pt}%
+ \draw[(1,0,0)]\lines{(0,0), (5,5), (10,0)}%
+ \pointcolor{(0,.8,0)}%
+ \point[3pt]{(2.5,7.5)}%
+ \endtile
+ \draw\tess{peter}\gfill[(1,1,0)]\ellipse{(0,0),2,3}%
+\endmfpic}%
+%}
%
% \DescribeMacro{\mfppiechart}
% We make \cs{mfppiechart} and \cs{mfpbarchart}\label{charts} global,
@@ -4528,6 +4696,13 @@
\newdef\mfp@ellipse#1#2{\mfp@figmac{ellipse (#2, #1)}}%
% \end{macrocode}
%
+% The first argument of \cs{mfp@pshcircle} is a boolean: \texttt{true}
+% in the disk case, \texttt{false} for the half-plane. The second argument
+% should be \marg{\meta{center},\meta{radius}}.
+% \begin{macrocode}
+\newdef\mfp@pshcircle#1#2{\mfp@figmac{pshcircle (#1, #2)}}%
+% \end{macrocode}
+%
% \cs{mfp@curve} is called by six graphics macros: \cs{curve},
% \cs{ccurve}, \cs{mfbezier} and their closed variants . Its two arguments
% are the name of a \grafbase{} command, and \mfc{true} or \mfc{false}.
@@ -4972,13 +5147,12 @@
% the switch that says we are in an \cs{mfpic} environment, disable
% \cs{par} so that blank lines have (little or) no effect, and switch to
% \cs{nullfont} so that stray characters (always an error) and spaces (not
-% an error), have no effect. I don't know whether \cs{relax} is a better
+% an error) have no effect. I don't know whether \cs{relax} is a better
% disabling definition for \cs{par} than \cs{@empty}.
% \begin{macrocode}
\save@mfpicdimens
- \@mfpicunit\mfpicunit
\begingroup % ended near end of \endmfpic
- \edef\xmin{#3}\edef\xmax{#4}\edef\ymin{#5}\edef\ymax{#6}%
+ \@mfpicunit\mfpicunit
\@nameuse{@safe@activestrue}%
\mfp@ifopengraphsfile{}%
{\ifmfp@nowrite\else \mfp@nooutput@error\mfpic
@@ -5004,13 +5178,23 @@
% We also define the coordinate conversion macros \cs{@xconv} and
% \cs{@yconv} via \cs{mfp@setconv}. These are used to calculate the
% nominal dimensions of the picture and to position \TeX{} labels.
+% \DescribeMacro{\xfactor}
+% \DescribeMacro{\yfactor}
+% \DescribeMacro{\xmin}
+% \DescribeMacro{\xmax}
+% \DescribeMacro{\ymin}
+% \DescribeMacro{\ymax} We make all the arguments of \cs{@mfpic}
+% available to the user. Macro \cs{mfp@setconv} now also makes use of
+% them.
%
% We are going to add all text labels to a box \cs{@alltlabels} and put
% that whole box on top of the graph during \cs{endmfpic}.
% We initialize the box here, as well as the dimensions \cs{@tlabelsbot},
% etc.
% \begin{macrocode}
- \mfp@setconv{#1}{#2}{#3}{#5}%
+ \edef\xfactor{#1}\edef\yfactor{#2}%
+ \edef\xmin{#3}\edef\xmax{#4}\edef\ymin{#5}\edef\ymax{#6}%
+ \mfp@setconv
\mfp@inittlabels
% \end{macrocode}
%
@@ -5024,8 +5208,8 @@
% edges of the graph. These are all font dimensions, so they are global
% assignments.
% \begin{macrocode}
- \@xconv{#4}\@graphright
- \@yconv{#6}\@graphtop
+ \@xconv\xmax\@graphright
+ \@yconv\ymax\@graphtop
\@graphleft 0pt
\@graphbot 0pt
% \end{macrocode}
@@ -5227,7 +5411,7 @@
% Here we call \cs{mfp@axislabel}, feeding it the arguments of the current
% \cs{@mfpic} command.
% \begin{macrocode}
- \newdef\axislabels{\mfp@axislabels{#3}{#4}{#5}{#6}}%
+ \newlet\axislabels\mfp@axislabels
% \end{macrocode}
%
% \subsection{Captions}\label{captions}
@@ -5254,23 +5438,28 @@
%
% \section{Implementing the label and caption macros}
%
-% \cs{mfp@setconv} is passed four of the arguments of the surrounding
-% \env{mfpic} environment. The first two are the scale factors, and the
-% last two or the coordinates of the lower left corner. It defines two
-% macros used to convert graph coordinates into actual dimensions relative
-% to the lower left corner of the picture. The second argument of
-% \cs{@xconv} and \cs{@yconv} is a dimension register in which the
-% converted result is returned. We make the final assignment global for
-% consistency (font dimension assignments are always global).
-% \begin{macrocode}
-\newdef\mfp@setconv#1#2#3#4{% #1,#2=xscale,yscale. #3,#4=xmin,ymin.
+% \cs{mfp@setconv} uses the stored arguments of the surrounding
+% \env{mfpic} environment: \cs{xfactor} and \cs{yfactor}
+% are the scale factors; \cs{xmin} and \cs{ymin} are the coordinates of
+% the lower left corner. It defines two macros used to convert graph
+% coordinates into actual dimensions relative to the lower left corner of
+% the picture. The second argument of \cs{@xconv} and \cs{@yconv} is a
+% dimension register in which the converted result is returned. We make
+% the final assignment global for consistency (font dimension assignments
+% are always global). We don't really need to define \cs{mfp@setconv}
+% and then call it. We could just define \cs{@xconv} and \cs{@yconv}.
+% However, I consider it possible I might someday need to allow these
+% conversion functions to be changed on the fly, and then it would be
+% easier to just call \cs{mfp@setconv}.
+% \begin{macrocode}
+\newdef\mfp@setconv{%
\def\@xconv##1##2{% ##1 = coord. ##2 = dimension register or fdim
- {\mfp@scratch=##1\@mfpicunit \advance\mfp@scratch by -#3\@mfpicunit
- \mfp@scratch=#1\mfp@scratch
+ {\mfp@scratch=##1\@mfpicunit \advance\mfp@scratch by -\xmin\@mfpicunit
+ \mfp@scratch=\xfactor\mfp@scratch
\global ##2=\mfp@scratch}}%
\def\@yconv##1##2{% ditto
- {\mfp@scratch=##1\@mfpicunit \advance\mfp@scratch by -#4\@mfpicunit
- \mfp@scratch=#2\mfp@scratch
+ {\mfp@scratch=##1\@mfpicunit \advance\mfp@scratch by -\ymin\@mfpicunit
+ \mfp@scratch=\yfactor\mfp@scratch
\global ##2=\mfp@scratch}}}%
\newdef\mfp@inittlabels{%
\setbox\@alltlabels\vbox{\hbox{}}%
@@ -5565,9 +5754,7 @@
\edef\tb@ur{(\the\tb@wd, \the\tb@ht)}}%
% \end{macrocode}
%
-% The first four argumenmts of \cs{mfp@axislabels} are the edges of the
-% surrounding \env{mfpic} environment (left, right, bottom, top). The
-% fifth is the axis letter.
+% The argument of \cs{mfp@axislabels} is the axis letter.
%
% We start by determining the default justification. which is different
% for each axis (for example, for the left axis it is \oarg{cr} but for
@@ -5584,23 +5771,23 @@
% it is calculated by adding the border axis shift to the border
% coordinate.
% \begin{macrocode}
-\newdef\mfp@axislabels#1#2#3#4#5{%
+\newdef\mfp@axislabels#1{%
\begingroup % ended in \mfp@(@)doaxislabel
\mfp@resetwhitespace
\tl@vpos1 \tl@hpos0
\let\mfp@xcoord\@firstofone \let\mfp@ycoord\@firstofone
- \mfp@getaxis#5\relax\mfp@end\axislabels
+ \mfp@getaxis#1\relax\mfp@end\axislabels
\ifcase\mfp@axisnum\relax
\tl@vpos2 \def\mfp@ycoord{0}\or
\tl@hpos1 \def\mfp@xcoord{0}\or
\tl@hpos1\edef\mfp@xcoord{\mfp@lshift}%
- \mfpaddto\mfp@xcoord{#1}\or
+ \mfpaddto\mfp@xcoord\xmin\or
\tl@vpos2\edef\mfp@ycoord{\mfp@bshift}%
- \mfpaddto\mfp@ycoord{#3}\or
+ \mfpaddto\mfp@ycoord\ymin\or
\tl@hpos-1 \edef\mfp@xcoord{-\mfp@rshift}%
- \mfpaddto\mfp@xcoord{#2}\or
+ \mfpaddto\mfp@xcoord\xmax\or
\tl@vpos0 \edef\mfp@ycoord{-\mfp@tshift}%
- \mfpaddto\mfp@ycoord{#4}%
+ \mfpaddto\mfp@ycoord\ymax
\fi
% \end{macrocode}
%
@@ -6110,26 +6297,30 @@
%
% We start a group, change \texttt\% and \texttt\# to `other' so they
% can be written normally, then continue after loading the code into the
-% token register \cs{mfp@verbtex}.
+% token register \cs{mfp@toks}.
% \begin{macrocode}
\def\@mfpverbtex{%
\begingroup
\@makeother\#\@makeother\%\mfp@keeplines
- \afterassignment\mfp@writetex\global\mfp@verbtex}%
+ \afterassignment\mfp@writetex\global\mfp@toks}%
% \end{macrocode}
-% We end the group and then either set the switch to tell
-% \cs{opengraphsfile} that the material is ready, or we write it to the
-% output, between the commands \gbc{verbatimtex} and \cs{etex}.
+% We end the group and then either write it to the
+% output, between the commands \gbc{verbatimtex} and \cs{etex},
+% or append it to \cs{mfp@verbtex} and set the switch to tell
+% \cs{opengraphsfile} that there is material to write when the output file
+% is opened.
% \begin{macrocode}
\newif\ifmfp@verbtex
\def\mfp@writetex{%
\endgroup
\mfp@ifopengraphsfile
{\mfp@ifmpost
- {\mfsrc{ verbatimtex\@nl \the\mfp@verbtex}\mfcmd{etex}}%
- {\mfp@noMP@error\mfpverbtex}%
- \global\mfp@verbtexfalse\mfp@verbtex{}}%
- {\global\mfp@verbtextrue}}%
+ {\mfsrc{ verbatimtex\@nl \the\mfp@toks}\mfcmd{etex}}%
+ {\mfp@noMP@error\mfpverbtex}%
+ \global\mfp@verbtexfalse\global\mfp@verbtex{}}%
+ {\edef\mfp@tempa{\the\mfp@verbtex\the\mfp@toks}%
+ \global\mfp@verbtex\@xp{\mfp@tempa}%
+ \global\mfp@verbtextrue}}%
% \end{macrocode}
%
%