[metapost] Re: all intersections between two paths

Dan Luecking luecking at uark.edu
Thu Jan 20 18:23:30 CET 2005


At 03:00 AM 1/20/2005, you wrote:
>Larry Siebenmann wrote:
>>When writing macros common to MF and MP, is there
>>a *conventional* way for macros to decide which of MF or MP
>>is running?
>
>boolean ThisIsMp ;
>
>ThisIsMp := known miterlimit ;
>
>message if ThisIsMp : "METAPOST" else : "METAFONT" fi ;
>
>end .

This is what I use in grafbase.mf,mp (part of mfpic):

boolean METAPOST;
METAPOST := known color Karl Frederich Gauss; % :-)

While MF doesn't know miterlimit by default, it could conceivably
be defined as a variable by some previously loaded macro package.
In MP, "color X" is either true of false, and so always known
(whatever X is). But in MF, this is either an unlikely variable name
(color, with three suffixes) or some macro "color" followed by an
unlikely variable name. (Or something else entirely, see below.)

MF makes this true if someone previously says "let color=numeric;".
Grafbase actually does this, but after the test. If someone defines
color in a way that causes a syntax error this may fail, but unless the
error is fatal, the value of the boolean will usually be false, since
that's what MF does for "not implemented" boolean assignments.

I've concluded there is no guaranteed way to determine which of the two
is running, barring a change to both programs.

On the topic of another thread, grafbase.dtx includes a tightbbox macro
to find the bounding box of a path in MF, and a tbbox macro to find the
bounding box of an array of paths. I think they are similar to Jacko's
method (which I didn't study too closely). Neither is actually used (they
are not unpacked to grafbase.mf), but rather a faster, approximate method
that just checks certain control points.


Dan


Daniel H. Luecking
Department of Mathematical Sciences
University of Arkansas 



More information about the metapost mailing list