MetaPost

Last updated
MetaPost
MPlogo.svg
Paradigm imperative, typesetting
Designed by John D. Hobby
Developer Taco Hoekwater, Luigi Scarso
First appeared1994 (1994)
Stable release
1.8 / 17 June 2013;10 years ago (2013-06-17)
Preview release
2.0rc2 / 19 February 2018;6 years ago (2018-02-19)
Typing discipline duck, dynamic, strong
OS Cross-platform
License LGPL
Website tug.org/metapost
Influenced by
Metafont

MetaPost refers to both a programming language and the interpreter of the MetaPost programming language. Both are derived from Donald Knuth's Metafont language and interpreter. MetaPost produces vector graphic diagrams from a geometric/algebraic description. The language shares Metafont's declarative syntax for manipulating lines, curves, points and geometric transformations. However,

Contents

Many of the limitations of MetaPost derive from features of Metafont. For instance, MetaPost does not support all features of PostScript. Most notably, paths can have only one segment (so that regions are simply connected), and regions can be filled only with uniform colours. PostScript level 1 supports tiled patterns and PostScript 3 supports Gouraud shading.

Availability and usage

MetaPost is distributed with many distributions of the TeX and Metafont framework, for example, it is included in the MiKTeX and the TeX Live distributions.

The encapsulated postscript produced by Metapost can be included in LaTeX, ConTeXt, and TeX documents via standard graphics inclusion commands. The encapsulated postscript output can also be used with the PDFTeX engine, thus directly giving PDF. This ability is implemented in ConTeXt and in the LaTeX graphics package, and can be used from plain TeX via the supp-pdf.tex macro file.

ConTeXt and LuaTeX supports the inclusion of MetaPost code within the input file. Inclusion of MetaPost code in LaTeX is also possible by using LaTeX-packages, for example gmp or mpgraphics.

Examples

This is a single file example.mp which when processed by the MetaPost interpreter (via the command mpost on Linux) produces three eps files example.1, example.2, example.3. These are pictured on the right.

example outputs Metapost ex.svg
example outputs
transformpagecoords;pagecoords:=identityscaled10mmshifted(100mm,150mm);beginfig(1)fill((0,0)--(2,0)--(2,1)--(1,1)--(1,2)--(0,2)--cycle)transformedpagecoordswithcolorgreen;draw((2,0)..(2,1)..(1,1)..(1,2)..(0,2))transformedpagecoords;drawarrow((0,0)--(2,2))transformedpagecoords;endfig;beginfig(2)draw(fori=0upto7:dir(135i)--endforcycle)transformedpagecoords;endfig;pagecoords:=identityscaled15mmshifted(100mm,150mm);beginfig(3);% declare paths to be usedpathp[],p[]t;% set up points by defining relationshipsz1=(0,0);z2=z1+2up;z3=z1+whatever*dir(60)=z2+whatever*dir(-50);z4=z3+(-1.5,-.5);z5=z1+dir(135);z0=whatever[z1,z2]=whatever[z3,z4];% set up pathsp0=fullcircleyscaled.5rotated45shiftedz0;p1=z2---z4..z0..z3---z1;p2=p1cutbeforep0cutafterp0;p3=p0cutbeforep1cutafterp1;p4=p2---p3---cycle;% define transformed versions of paths and pointsfori=0upto4:p[i]t=p[i]transformedpagecoords;endforfori=0upto5:z[i]t=z[i]transformedpagecoords;endfor% do some drawingfillp4twithcolor(1,1,0.2);drawz1t---z2twithcolor.5white;drawz3t---z4twithcolor.5white;pickuppencircle;drawp0tdashedwithdotsscaled.3;drawp1tdashedevenly;drawp2twithcolorblue;drawp3twithcolorred;label.lrt(btex $z_0$ etex,z0t);label.llft(btex $z_1$ etex,z1t);label.top(btex $z_2$ etex,z2t);label.rt(btex $z_3$ etex,z3t);label.llft(btex $z_4$ etex,z4t);fori=0upto4:drawdotz[i]twithpenpencirclescaled2;endforendfig;bye

The resulting three eps files can be used in TeX via LaTeX's \includegraphics command, ConTeXt's \externalfigure, Plain TeX's \epsfbox command, or (in Plain pdftex) the \convertMPtoPDF command from supp-pdf.tex. To view or print the third diagram, this inclusion is necessary, as the TeX fonts (Computer Modern) are not included in the eps files produced by MetaPost by default.

See also

Related Research Articles

<span class="mw-page-title-main">Bézier curve</span> Curve used in computer graphics and related fields

A Bézier curve is a parametric curve used in computer graphics and related fields. A set of discrete "control points" defines a smooth, continuous curve by means of a formula. Usually the curve is intended to approximate a real-world shape that otherwise has no mathematical representation or whose representation is unknown or too complicated. The Bézier curve is named after French engineer Pierre Bézier (1910–1999), who used it in the 1960s for designing curves for the bodywork of Renault cars. Other uses include the design of computer fonts and animation. Bézier curves can be combined to form a Bézier spline, or generalized to higher dimensions to form Bézier surfaces. The Bézier triangle is a special case of the latter.

<span class="mw-page-title-main">Konrad Zuse</span> German computer scientist and engineer (1910–1995)

Konrad Ernst Otto Zuse was a German civil engineer, pioneering computer scientist, inventor and businessman. His greatest achievement was the world's first programmable computer; the functional program-controlled Turing-complete Z3 became operational in May 1941. Thanks to this machine and its predecessors, Zuse is regarded by some as the inventor and father of the modern computer.

TeX, stylized within the system as TeX, is a typesetting system which was designed and written by computer scientist and Stanford University professor Donald Knuth and first released in 1978. TeX is a popular means of typesetting complex mathematical formulae; it has been noted as one of the most sophisticated digital typographical systems.

Metafont is a description language used to define raster fonts. It is also the name of the interpreter that executes Metafont code, generating the bitmap fonts that can be embedded into e.g. PostScript. Metafont was devised by Donald Knuth as a companion to his TeX typesetting system.

<span class="mw-page-title-main">Root of unity</span> Number that has an integer power equal to 1

In mathematics, a root of unity, occasionally called a de Moivre number, is any complex number that yields 1 when raised to some positive integer power n. Roots of unity are used in many branches of mathematics, and are especially important in number theory, the theory of group characters, and the discrete Fourier transform.

<span class="mw-page-title-main">Device independent file format</span> Typesetting file format

The device independent file format (DVI) is the output file format of the TeX typesetting program, designed by David R. Fuchs and implemented by Donald E. Knuth in 1982. Unlike the TeX markup files used to generate them, DVI files are not intended to be human-readable; they consist of binary data describing the visual layout of a document in a manner not reliant on any specific image format, display hardware or printer. DVI files are typically used as input to a second program which translates DVI files to graphical data. For example, most TeX software packages include a program for previewing DVI files on a user's computer display; this program is a driver. Drivers are also used to convert from DVI to popular page description languages and for printing.

In geometry, an incidence relation is a heterogeneous relation that captures the idea being expressed when phrases such as "a point lies on a line" or "a line is contained in a plane" are used. The most basic incidence relation is that between a point, P, and a line, l, sometimes denoted P I l. If P I l the pair (P, l) is called a flag. There are many expressions used in common language to describe incidence (for example, a line passes through a point, a point lies in a plane, etc.) but the term "incidence" is preferred because it does not have the additional connotations that these other terms have, and it can be used in a symmetric manner. Statements such as "line l1 intersects line l2" are also statements about incidence relations, but in this case, it is because this is a shorthand way of saying that "there exists a point P that is incident with both line l1 and line l2". When one type of object can be thought of as a set of the other type of object (viz., a plane is a set of points) then an incidence relation may be viewed as containment.

<span class="mw-page-title-main">Xfig</span> Vector graphics editor for UNIX-like systems

Xfig is a free and open-source vector graphics editor which runs under the X Window System on most UNIX-compatible platforms.

<span class="mw-page-title-main">Computer Modern</span> Family of typefaces

Computer Modern is the original family of typefaces used by the typesetting program TeX. It was created by Donald Knuth with his Metafont program, and was most recently updated in 1992. Computer Modern, or variants of it, remains very widely used in scientific publishing, especially in disciplines that make frequent use of mathematical notation.

<span class="mw-page-title-main">ConTeXt</span> General-purpose document processor, derived from TeX

ConTeXt is a general-purpose document processor. Like LaTeX, it is derived from TeX. It is especially suited for structured documents, automated document production, very fine typography, and multilingual typesetting. It is based in part on the TeX typesetting system, and uses a document markup language for manuscript preparation. The typographical and automated capabilities of ConTeXt are extensive, including interfaces for handling microtypography, multiple footnotes and footnote classes, and manipulating OpenType fonts and features. Moreover, it offers extensive support for colors, backgrounds, hyperlinks, presentations, figure-text integration, and conditional compilation. It gives the user extensive control over formatting while making it easy to create new layouts and styles without learning the low-level TeX macro language.

A computer font is implemented as a digital data file containing a set of graphically related glyphs. A computer font is designed and created using a font editor. A computer font specifically designed for the computer screen, and not for printing, is a screen font.

<span class="mw-page-title-main">AMS Euler</span> Script typeface

AMS Euler is an upright cursive typeface, commissioned by the American Mathematical Society (AMS) and designed and created by Hermann Zapf with the assistance of Donald Knuth and his Stanford graduate students. It tries to emulate a mathematician's style of handwriting mathematical entities on a blackboard, which is upright rather than italic. It blends very well with other typefaces made by Hermann Zapf, such as Palatino, Aldus and Melior, but very badly with the default TeX font Computer Modern. All the alphabets were implemented with the computer-assisted design system Metafont developed by Knuth. Zapf designed and drew the Euler alphabets in 1980–81 and provided critique and advice of digital proofs in 1983 and later. The typeface family is copyright by American Mathematical Society, 1983. Euler Metafont development was done by Stanford computer science and/or digital typography students; first Scott Kim, then Carol Twombly and Daniel Mills, and finally David Siegel, all assisted by John Hobby. Siegel finished the Metafont Euler digitization project as his M.S. thesis in 1985.

In geometry, the Hessian curve is a plane curve similar to folium of Descartes. It is named after the German mathematician Otto Hesse. This curve was suggested for application in elliptic curve cryptography, because arithmetic in this curve representation is faster and needs less memory than arithmetic in standard Weierstrass form.

<span class="mw-page-title-main">WinEdt</span>

WinEdt is a shareware Unicode (UTF-8) editor and shell for Microsoft Windows. It is primarily used for the creation of TeX documents, but can also be used to edit HTML or any other type of text file. It can be configured to run as a front-end for a variety of TeX systems, including MiKTeX, fpTeX and TeX Live. WinEdt's highlighting schemes can be customized for different modes and its spell checking functionality supports multi-lingual setups, with dictionaries (word-lists) for many languages available for downloading from WinEdt's Community Site. It supports DVI and PDF workflow.

<span class="mw-page-title-main">Newton fractal</span> Boundary set in the complex plane

The Newton fractal is a boundary set in the complex plane which is characterized by Newton's method applied to a fixed polynomial p(z) ∈ [z] or transcendental function. It is the Julia set of the meromorphic function zzp(z)/p′(z) which is given by Newton's method. When there are no attractive cycles (of order greater than 1), it divides the complex plane into regions Gk, each of which is associated with a root ζk of the polynomial, k = 1, …, deg(p). In this way the Newton fractal is similar to the Mandelbrot set, and like other fractals it exhibits an intricate appearance arising from a simple description. It is relevant to numerical analysis because it shows that (outside the region of quadratic convergence) the Newton method can be very sensitive to its choice of start point.

LuaTeX is a TeX-based computer typesetting system which started as a version of pdfTeX with a Lua scripting engine embedded. After some experiments it was adopted by the TeX Live distribution as a successor to pdfTeX. Later in the project some functionality of Aleph was included. The project was originally sponsored by the Oriental TeX project, founded by Idris Samawi Hamid, Hans Hagen, and Taco Hoekwater.

The computer program pdfTeX is an extension of Knuth's typesetting program TeX, and was originally written and developed into a publicly usable product by Hàn Thế Thành as a part of the work for his PhD thesis at the Faculty of Informatics, Masaryk University, Brno, Czech Republic. The idea of making this extension to TeX was conceived during the early 1990s, when Jiří Zlatuška and Phil Taylor discussed some developmental ideas with Donald Knuth at Stanford University. Knuth later met Hàn Thế Thành in Brno during his visit to the Faculty of Informatics to receive an honorary doctorate from Masaryk University.

For digital image processing, the Focus recovery from a defocused image is an ill-posed problem since it loses the component of high frequency. Most of the methods for focus recovery are based on depth estimation theory. The Linear canonical transform (LCT) gives a scalable kernel to fit many well-known optical effects. Using LCTs to approximate an optical system for imaging and inverting this system, theoretically permits recovery of a defocused image.

In mathematics, a Carlyle circle is a certain circle in a coordinate plane associated with a quadratic equation; it is named after Thomas Carlyle. The circle has the property that the solutions of the quadratic equation are the horizontal coordinates of the intersections of the circle with the horizontal axis. Carlyle circles have been used to develop ruler-and-compass constructions of regular polygons.

Sony Xperia Z series is a line of flagship Android smartphones and tablets in the Sony Xperia series manufactured by Sony Mobile.

References