Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
MetaPost
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{short description|Programming language}} {{multiple issues| {{how-to|date=January 2016}} {{more footnotes needed|date=January 2016}} }} {{Infobox programming language | name = MetaPost | logo = MPlogo.svg | paradigm = [[Imperative programming|imperative]], [[typesetting]] | released = {{Start date|1994}} | designer = John D. Hobby | developer = Taco Hoekwater, Luigi Scarso | latest_release_version = 1.8 | latest_release_date = {{start date and age|2013|06|17|df=yes}} | latest_preview_version = 2.0rc2 | latest_preview_date = {{start date and age|2018|02|19|df=yes}} | typing = [[duck typing|duck]], [[dynamic typing|dynamic]], [[strong typing|strong]] | implementations = | dialects = | influenced by = [[Metafont]] | influenced = | operating_system = [[Cross-platform]] | license = [[LGPL]] | website = {{URL|http://tug.org/metapost}} | file_ext = }} '''MetaPost''' refers to both a [[programming language]] and the [[interpreter (computer software)|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, * 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 [[encapsulated PostScript|EPS]], [[Scalable Vector Graphics|SVG]], or [[Portable Network Graphics|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 curve]]s) * Metafont output is monochrome, whereas MetaPost uses [[RGB]] or [[CMYK]] 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]]. * 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]]. ==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 [[Portable Document Format|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 <code>gmp</code> or <code>mpgraphics</code>. ==Examples== This is a single file <samp>example.mp</samp> which when processed by the MetaPost interpreter (via the command <code>mpost</code> on [[Linux]]) produces three eps files <samp>example.1</samp>, <samp>example.2</samp>, <samp>example.3</samp>. These are pictured on the right. [[Image:Metapost ex.svg|thumb|198px|right|example outputs]] <syntaxhighlight lang="octave"> 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[z3,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[i]t=p[i] transformed pagecoords; endfor for i=0 upto 5: z[i]t=z[i] 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[i]t withpen pencircle scaled 2; endfor endfig; bye </syntaxhighlight> The resulting three eps files can be used in [[TeX]] via [[LaTeX]]'s <code>\includegraphics</code> command, [[ConTeXt]]'s <code>\externalfigure</code>, Plain TeX's <code>\epsfbox</code> command, or (in Plain pdftex) the <code>\convertMPtoPDF</code> command from <samp>supp-pdf.tex</samp>. 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== {{Portal|Free and open-source software}} * [[PSTricks]] * [[PGF/TikZ]] * [[METATYPE1]] * [[Asymptote (vector graphics language)|Asymptote]] ==References== {{Refbegin}} * {{cite web|url=http://wiki.contextgarden.net/MetaFun|title=MetaFun|type=modules for Metapost|last=Hagen|first=Hans}} * {{cite book|last=Knuth|first=Donald|author-link=Donald Knuth|title=The [[METAFONT]]book|series=[[Computers and Typesetting]]|volume=C|publisher=[[Addison-Wesley]]|year=1986|isbn=0-201-13444-6}} * {{cite web|title=Comprehensive T<sub>E</sub>X Archive Network|type=[[CTAN]]|url=http://www.ctan.org/|publisher=Repository of the T<sub>E</sub>X source and hundreds of add-ons and style files}} * {{cite web|title=(La)TeX Navigator provides 305 simple MetaPost examples|url=http://tex.loria.fr/prod-graph/zoonekynd/metapost/metapost.html|access-date=2006-11-17|archive-url=https://web.archive.org/web/20130727021112/http://tex.loria.fr/prod-graph/zoonekynd/metapost/metapost.html|archive-date=2013-07-27|url-status=dead}} * {{cite journal|last=Hoekwater|first=Taco|url=http://www.tug.org/TUGboat/Articles/tb27-1/tb86hoekwater-metapost.pdf|title=MetaPost developments—autumn 2006|journal=TUGboat|volume=27|issue=1|year=2006}} {{Refend}} ==External links== * The TeX Users Group ([[TeX Users Group|TUG]]) http://www.tug.org/ has a page devoted to MetaPost: http://www.tug.org/metapost.html {{Vector graphics markup languages}} {{Free and open-source typography}} {{DEFAULTSORT:Metapost}} [[Category:Programming languages created in 1994]] [[Category:Declarative programming languages]] [[Category:Domain-specific programming languages]] [[Category:Free TeX software]] [[Category:PostScript]] [[Category:Public-domain software]] [[Category:Vector graphics markup languages]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite book
(
edit
)
Template:Cite journal
(
edit
)
Template:Cite web
(
edit
)
Template:Free and open-source typography
(
edit
)
Template:Infobox programming language
(
edit
)
Template:Multiple issues
(
edit
)
Template:Portal
(
edit
)
Template:Refbegin
(
edit
)
Template:Refend
(
edit
)
Template:Short description
(
edit
)
Template:Vector graphics markup languages
(
edit
)