Changes

Jump to navigation Jump to search
255 bytes removed ,  13:17, 26 November 2012
Add examples
* [http://tex.loria.fr/prod-graph/zoonekynd/metapost/metapost.html Lots of examples]
== Using MetaPost in ConTeXt ==
== Troubleshooting plain MetaPost ==* Test if MetaPost With {{cmd|startuseMPgraphic}}, you define a piece of graphics code that is installed on your system. * create testprocessed anew every time the graphic is placed with {{cmd|useMPgraphic}}.mp containing this:
beginfig(1)<context> draw \def\mycolor{.625red} \startuseMPgraphic{name} fill fullcircle scaled 3cm 20pt withcolor \mycolor; endfig ;\stopuseMPgraphic  end ;red: \useMPgraphic{name}
* apply MetaPost on the testfile\def\mycolor{.625blue}blue: \useMPgraphic{name}</context>
mp testFor graphics that are the same every time, it is better to use {{cmd|startreuseableMPgraphic}}: the graphic is compiled only once, and the one resulting picture can be placed at various points with {{cmd|reuseMPgraphic}}.mp or mpost test.mp
* that should create a postscript file test.1<context>* open test.1 with a postscript viewer like ghostview, okular, … You should see a circle\def\mycolor{.625red}
== Troubleshooting MetaPost embedded in ConTeXt ==\startreusableMPgraphic{name} fill fullcircle scaled 20pt withcolor \mycolor;\stopreusableMPgraphic
* create test.tex containing thisred:\reuseMPgraphic{name}
\starttext def\startMPcodemycolor{.625blue} draw fullcircle scaled 3cm; blue: \stopMPcodereuseMPgraphic{name} \stoptext</context>
* for mkii When reusing a graphic is not important, you need to have write18 support enabled and run texexec --pdf testcan simply use {{cmd|startMPcode}}.tex
* for mkiv run<context>\startMPcode fill fullcircle scaled 20pt withcolor .625green; \stopMPcode</context test.tex>
* that should create a pdf file testSee also section 3.pdf* open test3 of [[manual:metafun-s.pdf with a pdf viewer like acroread, okular... You should see a circle|MetaFun manual]].
== Different Packages, Extensions & Applications of Metapost ==
* [http://asymptote.sourceforge.net/ Asymptote] - inspired by MetaPost & fully generalizes MetaPost path construction algorithms to three-dimensions
== Using MP in ConTeXt Testing plain MetaPost ==The first way To test whether MetaPost is installed on your system, create a usable graphicfile called {{code|test. Such a graphic is calculated anew each time it is used. An examplemp}}:
<texcode> beginfig(1)\startuseMPgraphic{name} fill draw fullcircle scaled 5cm withcolor red3cm ; endfig ;\stopuseMPgraphic end ;
\useMPgraphic{name}</texcode>* apply MetaPost on the testfile
As said, this graphic is calculated each time it is placed, which can be time consuming mp test. Apart from the time aspect, this also means that the graphic itself is incorporated many timesmp or mpost test. Therefore, for graphics that don’t change, CONTEXT provides reusable graphics:mp
<texcode>* that should create a postscript file test.1\startreusableMPgraphic{name} fill fullcircle scaled 200pt withcolor * open test.1 with a postscript viewer like Ghostview, Okular, … You should see a circle.625yellow;\stopreusableMPgraphic
\reuseMPgraphic{name}</texcode>== Testing MetaPost embedded in ConTeXt ==
When reusing a graphic If MetaPost is not so important installed on your system and you just want to include something inlineworking correctly, you can also use the following:
<texcode> \starttext \startMPcode fill draw fullcircle scaled 200pt withcolor .625yellow3cm; \stopMPcode</texcode> \stoptext
See also section 3.3 of [[manual:metafun* for mkii you need to have write18 support enabled and run texexec --s.pdf|MetaFun manual]]test.tex
=== Examples ===* for mkiv run context test.tex
{{todo|Enable support for Metapost code when running ConTeXt online* that should create a pdf file test. This will allow easy creation of Metapost examples, including both source code and resulted figurepdf* open test.}} Currently, running online Metapost code, pdf with a pdf viewer like this exampleAdobe Acrobat, does not return anythingOkular..<pre><context source="yes" text="produces">\startMPcode fill fullcircle scaled 200pt withcolor You should see a circle.625yellow;\stopMPcode</context></pre>
== Other Links ==

Navigation menu