Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

MetaPost

From Wikipedia, the free encyclopedia
Programming language
This article has multiple issues. Please helpimprove it or discuss these issues on thetalk page.(Learn how and when to remove these messages)
This articlecontainsinstructions, advice, or how-to content. Please helprewrite the content so that it is more encyclopedic ormove it toWikiversity,Wikibooks, orWikivoyage.(January 2016)
This article includes a list ofgeneral references, butit lacks sufficient correspondinginline citations. Please help toimprove this article byintroducing more precise citations.(January 2016) (Learn how and when to remove this message)
(Learn how and when to remove this message)
MetaPost
Paradigmimperative,typesetting
Designed byJohn D. Hobby
DeveloperTaco Hoekwater, Luigi Scarso
First appeared1994 (1994)
Stable release
1.8 / 17 June 2013; 11 years ago (2013-06-17)
Preview release
2.0rc2 / 19 February 2018; 7 years ago (2018-02-19)
Typing disciplineduck,dynamic,strong
OSCross-platform
LicenseLGPL
Websitetug.org/metapost
Influenced by
Metafont

MetaPost refers to both aprogramming language and theinterpreter of the MetaPost programming language. Both are derived fromDonald Knuth'sMetafont 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 producesEPS,SVG, orPNG 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 usesRGB orCMYK colors.
  • The MetaPost language can include text labels on the diagrams, either strings from a specified font, or anything else that can be typeset withTeX.
  • 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 ofPostScript. Most notably, paths can have only one segment (so that regions aresimply connected), and regions can be filled only with uniform colours. PostScript level 1 supports tiled patterns and PostScript 3 supportsGouraud shading.

Availability and usage

[edit]

MetaPost is distributed with many distributions of theTeX and Metafont framework, for example, it is included in theMiKTeX and theTeX Live distributions.

The encapsulated postscript produced by Metapost can be included inLaTeX,ConTeXt, andTeX documents via standard graphics inclusion commands. The encapsulated postscript output can also be used with thePDFTeX engine, thus directly givingPDF. 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 andLuaTeX supports the inclusion of MetaPost code within the input file. Inclusion of MetaPost code in LaTeX is also possible by using LaTeX-packages, for examplegmp ormpgraphics.

Examples

[edit]

This is a single fileexample.mp which when processed by the MetaPost interpreter (via the commandmpost onLinux) produces three eps filesexample.1,example.2,example.3. These are pictured on the right.

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 inTeX viaLaTeX's\includegraphics command,ConTeXt's\externalfigure, Plain TeX's\epsfbox command, or (in Plain pdftex) the\convertMPtoPDF command fromsupp-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

[edit]

References

[edit]

External links

[edit]
Bytype
2D
3D
See also
Software
and libraries
Licenses
Operating system,
corporate and
professional
Government
typefaces
Other
typefaces
Groups and
people
Retrieved from "https://en.wikipedia.org/w/index.php?title=MetaPost&oldid=1267041912"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp