% $Id: mp.w 2091 2016-09-16 23:07:58Z luigi $ % % This file is part of MetaPost; % the MetaPost program is in the public domain. % See the code in mpost.w for more info. % Here is TeX material that gets inserted after \input webmac \def\hang{\hangindent 3em\noindent\ignorespaces} \def\textindent#1{\hangindent2.5em\noindent\hbox to2.5em{\hss#1 }\ignorespaces} \def\ps{PostScript} \def\psqrt#1{\sqrt{\mathstrut#1}} \def\k{_{k+1}} \def\pct!{{\char`\%}} % percent sign in ordinary text \font\tenlogo=logo10 % font used for the METAFONT logo \font\logos=logosl10 \def\MF{{\tenlogo META}\-{\tenlogo FONT}} \def\MP{{\tenlogo META}\-{\tenlogo POST}} \def\<#1>{$\langle#1\rangle$} \def\section{\mathhexbox278} \let\swap=\leftrightarrow \def\round{\mathop{\rm round}\nolimits} \mathchardef\vbv="026A % synonym for `\|' \def\vb{\relax\ifmmode\vbv\else$\vbv$\fi} \def\(#1){} % this is used to make section names sort themselves better \def\9#1{} % this is used for sort keys in the index via @@:sort key}{entry@@> \def\title{MetaPost} \pdfoutput=1 \pageno=3 @* Introduction. This is \MP\ by John Hobby, a graphics-language processor based on D. E. Knuth's \MF. Much of the original Pascal version of this program was copied with permission from MF.web Version 1.9. It interprets a language very similar to D.E. Knuth's METAFONT, but with changes designed to make it more suitable for PostScript output. The main purpose of the following program is to explain the algorithms of \MP\ as clearly as possible. However, the program has been written so that it can be tuned to run efficiently in a wide variety of operating environments by making comparatively few changes. Such flexibility is possible because the documentation that follows is written in the \.{WEB} language, which is at a higher level than C. A large piece of software like \MP\ has inherent complexity that cannot be reduced below a certain level of difficulty, although each individual part is fairly simple by itself. The \.{WEB} language is intended to make the algorithms as readable as possible, by reflecting the way the individual program pieces fit together and by providing the cross-references that connect different parts. Detailed comments about what is going on, and about why things were done in certain ways, have been liberally sprinkled throughout the program. These comments explain features of the implementation, but they rarely attempt to explain the \MP\ language itself, since the reader is supposed to be familiar with {\sl The {\logos METAFONT\/}book} as well as the manual @.WEB@> @:METAFONTbook}{\sl The {\logos METAFONT\/}book@> {\sl A User's Manual for MetaPost}, Computing Science Technical Report 162, AT\AM T Bell Laboratories. @ The present implementation is a preliminary version, but the possibilities for new features are limited by the desire to remain as nearly compatible with \MF\ as possible. On the other hand, the \.{WEB} description can be extended without changing the core of the program, and it has been designed so that such extensions are not extremely difficult to make. The |banner| string defined here should be changed whenever \MP\ undergoes any modifications, so that it will be clear which version of \MP\ might be the guilty party when a problem arises. @^extensions to \MP@> @^system dependencies@> @d default_banner "This is MetaPost, Version 1.9991" /* printed when \MP\ starts */ @d true 1 @d false 0 @= #define metapost_version "1.9991" @ The external library header for \MP\ is |mplib.h|. It contains a few typedefs and the header defintions for the externally used fuctions. The most important of the typedefs is the definition of the structure |MP_options|, that acts as a small, configurable front-end to the fairly large |MP_instance| structure. @(mplib.h@>= #ifndef MPLIB_H #define MPLIB_H 1 #include #ifndef HAVE_BOOLEAN typedef int boolean; #endif @ typedef struct MP_instance *MP; @ typedef struct MP_options { @