MetaPost
   HOME

TheInfoList



OR:

MetaPost refers to both a
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming ...
and the interpreter of the MetaPost programming language. Both are derived from
Donald Knuth Donald Ervin Knuth ( ; born January 10, 1938) is an American computer scientist, mathematician, and professor emeritus at Stanford University. He is the 1974 recipient of the ACM Turing Award, informally considered the Nobel Prize of computer sc ...
'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, * Metafont is set up to produce fonts, in the form of image files (in .gf format) with associated font metric files (in .tfm format), whereas MetaPost produces EPS, SVG, or PNG files * The output of Metafont consists of the fonts at a fixed resolution in a raster-based format, whereas MetaPost's output is vector-based graphics (lines, Bézier curves) * Metafont output is monochrome, whereas MetaPost uses
RGB The RGB color model is an additive color model in which the red, green and blue primary colors of light are added together in various ways to reproduce a broad array of colors. The name of the model comes from the initials of the three addi ...
or
CMYK The CMYK color model (also known as process color, or four color) is a subtractive color model, based on the CMY color model, used in color printing, and is also used to describe the printing process itself. The abbreviation ''CMYK'' refers ...
colors. * The MetaPost language can include text labels on the diagrams, either strings from a specified font, or anything else that can be typeset with
TeX Tex may refer to: People and fictional characters * Tex (nickname), a list of people and fictional characters with the nickname * Joe Tex (1933–1982), stage name of American soul singer Joseph Arrington Jr. Entertainment * ''Tex'', the Italian ...
. * Starting with version 1.8, Metapost allows floating-point arithmetic with 64 bits (default: 32 bit fixed-point arithmetic) 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 Gouraud shading, named after Henri Gouraud, is an interpolation method used in computer graphics to produce continuous shading of surfaces represented by polygon meshes. In practice, Gouraud shading is most often used to achieve continuous li ...
.


Availability and usage

MetaPost is distributed with many distributions of the
TeX Tex may refer to: People and fictional characters * Tex (nickname), a list of people and fictional characters with the nickname * Joe Tex (1933–1982), stage name of American soul singer Joseph Arrington Jr. Entertainment * ''Tex'', the Italian ...
and Metafont framework, for example, it is included in the
MiKTeX MiKTeX is a free and open-source distribution of the TeX/LaTeX typesetting system for Microsoft Windows (and for Mac and certain Linux distributions such as Ubuntu, Debian and Fedora). It also contains a set of related programs. MiKTeX provides ...
and the
TeX Live TeX Live is a cross-platform, free software distribution for the TeX typesetting system that includes major TeX-related programs, macro packages, and fonts. It is the replacement of its no-longer supported counterpart teTeX. It is now the def ...
distributions. The encapsulated postscript produced by Metapost can be included in
LaTeX Latex is an emulsion (stable dispersion) of polymer microparticles in water. Latexes are found in nature, but synthetic latexes are common as well. In nature, latex is found as a milky fluid found in 10% of all flowering plants (angiosperms ...
,
ConTeXt Context may refer to: * Context (language use), the relevant constraints of the communicative situation that influence language use, language variation, and discourse summary Computing * Context (computing), the virtual environment required to su ...
, and
TeX Tex may refer to: People and fictional characters * Tex (nickname), a list of people and fictional characters with the nickname * Joe Tex (1933–1982), stage name of American soul singer Joseph Arrington Jr. Entertainment * ''Tex'', the Italian ...
documents via standard graphics inclusion commands. The encapsulated postscript output can also be used with the
PDFTeX __NOTOC__ 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 In ...
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 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 (itself an extension of ε- ...
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 Linux ( or ) is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution, w ...
) produces three eps files example.1, example.2, example.3. These are pictured on the right. transform pagecoords; pagecoords:=identity scaled 10mm shifted (100mm,150mm); beginfig (1) fill ((0,0)--(2,0)--(2,1)--(1,1)--(1,2)--(0,2)--cycle) transformed pagecoords withcolor green; draw ((2,0)..(2,1)..(1,1)..(1,2)..(0,2)) transformed pagecoords; drawarrow ((0,0)--(2,2)) transformed pagecoords; endfig; beginfig (2) draw (for i=0 upto 7: dir (135i)-- endfor cycle) transformed pagecoords; endfig; pagecoords:=identity scaled 15mm shifted (100mm,150mm); beginfig (3); % declare paths to be used path p[],p[]t; % set up points by defining relationships z1=(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 3,z4 % set up paths p0=fullcircle yscaled .5 rotated 45 shifted z0 ; p1=z2---z4..z0..z3---z1; p2=p1 cutbefore p0 cutafter p0; p3=p0 cutbefore p1 cutafter p1; p4=p2---p3---cycle; % define transformed versions of paths and points for i=0 upto 4: p =p transformed pagecoords; endfor for i=0 upto 5: z =z transformed pagecoords; endfor % do some drawing fill p4t withcolor (1,1,0.2); draw z1t---z2t withcolor .5white; draw z3t---z4t withcolor .5white; pickup pencircle; draw p0t dashed withdots scaled .3; draw p1t dashed evenly; draw p2t withcolor blue; draw p3t withcolor red; 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); for i=0 upto 4: drawdot z withpen pencircle scaled 2; endfor endfig; bye The resulting three eps files can be used in
TeX Tex may refer to: People and fictional characters * Tex (nickname), a list of people and fictional characters with the nickname * Joe Tex (1933–1982), stage name of American soul singer Joseph Arrington Jr. Entertainment * ''Tex'', the Italian ...
via
LaTeX Latex is an emulsion (stable dispersion) of polymer microparticles in water. Latexes are found in nature, but synthetic latexes are common as well. In nature, latex is found as a milky fluid found in 10% of all flowering plants (angiosperms ...
's \includegraphics command,
ConTeXt Context may refer to: * Context (language use), the relevant constraints of the communicative situation that influence language use, language variation, and discourse summary Computing * Context (computing), the virtual environment required to su ...
'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 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 u ...
) are not included in the eps files produced by MetaPost by default.


See also

* PSTricks *
PGF/TikZ PGF/Ti''k''Z is a pair of languages for producing vector graphics (e.g., technical illustrations and drawings) from a geometric/algebraic description, with standard features including the drawing of points, lines, arrows, paths, circles, ellipse ...
* Metafont * METATYPE1 *
Asymptote In analytic geometry, an asymptote () of a curve is a line such that the distance between the curve and the line approaches zero as one or both of the ''x'' or ''y'' coordinates tends to infinity. In projective geometry and related context ...


References

* * * * *


External links

* The TeX Users Group ( TUG) http://www.tug.org/ has a page devoted to MetaPost: http://www.tug.org/metapost.html * Active development of MetaPost continues at https://web.archive.org/web/20070929092912/http://foundry.supelec.fr/projects/metapost/
Functional MetaPost
allows MetaPost to be used from the functional programming language
Haskell Haskell () is a general-purpose, statically-typed, purely functional programming language with type inference and lazy evaluation. Designed for teaching, research and industrial applications, Haskell has pioneered a number of programming lan ...
* John D. Hobby has a homepage at https://web.archive.org/web/20131003040005/http://ect.bell-labs.com/who/hobby/index.shtml and some other pages and publications devoted to MetaPost, though these are now a little dated ** Historic MetaPost homepage: https://web.archive.org/web/20081212090123/http://ect.bell-labs.com/who/hobby/MetaPost.shtml ** ''A User's Manual for MetaPost'' John D. Hobby. Available as a file mpman.ps distributed with MetaPost, or from th
Bell Labs web site
Also available i
PDF format
from
CTAN CTAN (an acronym for "Comprehensive TeX Archive Network") is the authoritative place where TeX related material and software can be found for download. Repositories for other projects, such as the MiKTeX distribution of TeX, constantly mirror mo ...
. * Troy Henderson'
Online MetaPost Previewer
{{DEFAULTSORT:Metapost Programming languages created in 1994 Declarative programming languages Domain-specific programming languages Free TeX software PostScript Public-domain software Vector graphics markup languages