MetaPost

MetaPost is a programming language on the one hand and on the other hand, the only known interpreter of the MetaPost language. Both are derived from Donald Knuth's Metafont language and interpreter. MetaPost can generate diagrams in PostScript or SVG vector graphics from a geometric / algebraic description. The language has the same syntax as Metafont to create lines, curves, dots and geometric transformations.

Comparison of Metafont and MetaPost

  • Metafont is created for the production of writings associated with this Font Metric files. MetaPost one creates PostScript files.
  • The output of Metafont consists of writings at a certain resolution in a raster-based format. MetaPost generates vector-based graphics.
  • In contrast to the monochrome outputs from metafont MetaPost uses a simple RGB scheme.
  • MetaPost can also attach labels to diagrams. This can include text from a specified font or simply anything that can be set by TeX be.
  • The Metafont interpreter was developed by Knuth under an open source license. This allowed John D. Hobby to adapt the interpreter for his benefit, thus originated MetaPost.

Use

MetaPost is shipped with many distributions of TeX and Metafont. The output of MetaPost can be easily used in TeX, ConTeXt, and LaTeX documents using standard commands.

Examples

This is example.mp a single file that creates three EPS files. To edit the input file mpost FILENAME command to call.

Transform pagecoords; pagecoords: = identity scaled shifted 10mm ( 100mm, 150mm ); beginfig (1)      fill ( ( 0.0 ) - (2.0 ) - ( 2.1 ) - ( 1.1 ) - ( 1.2 ) - ( 0.2 ) - cycle )          Transformed pagecoords with color 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 shifted 15mm ( 100mm, 150mm ); beginfig (3);      % Declare paths to be used      path p [] p [ ] t;      % Set up points by -defining relationships      Z1 = (0,0); z2 = z1 2 up;      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 = full circle yscaled .5 Rotated 45 shifted z0;      p1 = z2 - z4 .. z0 .. z1 z3 ---;      p2 = p1 p0 cutbefore cutafter p0;      p3 = p0 p1 cutbefore 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      P4T fill with color ( 1,1,0.2 );      draw z1t - z2t with color .5 white;      draw z3t - z4t with color .5 white;      pickup pencircle;      draw P0T dashed withdots scaled .3;      draw P1T dashed evenly;      p2t draw with color blue;      P3T draw with color 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 literature

  • Donald Knuth: The MetafontBOOK, ( Computers and Typesetting Volume C) 1986 Addison-Wesley ISBN 0-201-13444-6.
566077
de