Difference between revisions of "MetaFun - MetaPost in ConTeXt"

From Wiki
Jump to navigation Jump to search
m (merge content from MetaFun)
m
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
< [[Graphics]]|[[Metafun]]|[[Metapost]]>
+
__TOC__
  
ConTeXT provides a tight integration of TeX and [[MetaPost]]. MetaPost can used behind the scenes for some graphic trickery. This integration is also helpful for drawing figures in MetaPost and use them in the document. This page is a brief overview of some of the commonly used commands.
 
  
== \defineMPinstance and \setupMPinstance ==
+
MetaFun is ConTeXt extension the [[MetaPost]] language. It provides a tight integration of both TeX and [[MetaPost]]. MetaPost can used behind the scenes for some graphic trickery. This integration is also helpful for drawing figures in MetaPost and use them in the document.
  
{{cmd|defineMPinstance}} and {{cmd|setupMPinstance}} can be used to set up MetaPost invocations with particular features. One use case could be to select a sans serif font for all MetaPost
+
'''THE [[manual:metafun-p.pdf|MetaFun manual]]''', also available in a [[manual:metafun-s.pdf|screen version]].
labels.  
 
  
=== \startMPenvironment ===
 
  
{{cmd|startMPenvironment}} is a '''deprecated''' evironment in which one could place settings that one only wanted to apply in the MetaPost environment, but not in the document itself. One should use {{cmd|defineMPinstance}} and {{cmd|setupMPinstance}}, instead.
+
This page is a brief overview of some of the commonly used commands.
  
== \startMPinclusions ==
 
  
Inside {{cmd|startMPinclusions}} one can specify MetaPost files to ''input'', and also define MetaPost functions.
+
= Commonly used commands =
  
== \startuseMPgraphic and \useMPgraphic ==
+
; {{cmd|defineMPinstance}}, {{cmd|setupMPinstance}}: used to set up MetaPost invocations with particular features. One use case could be to select a sans serif font for all MetaPost labels.
 +
: {{cmd|startMPenvironment}} '''is DEPRECATED''' in which one could place settings that one only wanted to apply in the MetaPost environment, but not in the document itself. One should use {{cmd|defineMPinstance}} and {{cmd|setupMPinstance}}, instead.
  
{{cmd|startuseMPgraphic}}defines a piece of graphics code that is processed anew every time the graphic is placed with {{cmd|useMPgraphic}}.
+
; {{cmd|startMPinclusions}}: Inside, one can specify MetaPost files to ''input'', and also define MetaPost functions.
  
== \startreusableMPgraphic and \reuseMPgraphic ==
+
; {{cmd|startuseMPgraphic}}, {{cmd|useMPgraphic}}: defines a piece of graphics code that is processed anew every time the graphic is placed with {{cmd|useMPgraphic}}.
For graphics that are the same every time, it is better to use {{cmd|startreusableMPgraphic}}: the graphic is compiled only once, and the one resulting picture can be placed at various points with {{cmd|reuseMPgraphic}}.
 
  
== \startMPcode ==
+
; {{cmd|startreusableMPgraphic}}, {{cmd|reuseMPgraphic}}: For graphics that are the same every time, it is better to use {{cmd|startreusableMPgraphic}}: the graphic is compiled only once, and the one resulting picture can be placed at various points with {{cmd|reuseMPgraphic}}.
  
When reusing a graphic is not important, you can simply use {{cmd|startMPcode}}.
+
; {{cmd|startMPcode}}: When reusing a graphic is not important, you can simply use {{cmd|startMPcode}}.
  
== \startMPpage ==
+
; {{cmd|startMPpage}}: produces a page a containing MetaPost graphic. The page is just large enough to contain the graphic. The resulting pdf is self-contained (it has all the fonts embedded). This is useful if you want to send the figure to a coauthor or a journal.
  
{{cmd|startMPpage}} produces a page a containing MetaPost graphic. The page is just large enough to contain the graphic. The resulting pdf is self-contained (it has all the fonts embedded) This is useful if you want to send the figure to a coauthor or a journal.  
+
; {{cmd|startstaticMPfigure}}, {{cmd|usestaticMPfigure}}: The {{cmd|startuseMPgraphic}} series of commands were designed for using MetaPost for drawing fancy frames and backgrounds and not for using <i>stand-alone</i> graphics for a document. {{cmd|startstaticMPfigure}} creates a separate pdf file containing the graphic. This pdf can be included in the document using {{cmd|usestaticMPfigure}}. ConTeXt is clever enough to recompile the resulting MetaPost file only if something inside the {{cmd|startstaticMPfigure}} has changed.
  
== \startstaticMPfigure ==
+
= Documentation and links =
  
The {{cmd|startuseMPgraphic}} series of commands were designed for using MetaPost for drawing fancy frames and backgrounds and not for using <i>stand-alone</i> graphics for a document. {{cmd|startstaticMPfigure}} creates a separate pdf file containing the graphic. This pdf can be included in the document using {{cmd|usestaticMPfigure}}. ConTeXt is clever enough to recompile the resulting MetaPost file only if something inside the {{cmd|startstaticMPfigure}} has changed.
 
 
[[Category:Graphics]]
 
[[Category:Metapost]]
 
 
== See also ==
 
{{MetaPost see also}}
 
* section 3.3 of the [[manual:metafun-s.pdf|MetaFun manual]].
 
 
 
 
 
= TEMPO FROM METAFUN page==
 
 
MetaFun is Hans Hagen’s extension to (or module for) the [[MetaPost]] language.
 
 
 
==Documentation==
 
 
* [[manual:metafun-p.pdf|MetaFun manual]] ([[manual:metafun-s.pdf|screen]]) by Pragma
 
 
* [[manual:mmakempy.pdf|MakeMPY]]: create MetaPost outlines (by Pragma)
 
* [[manual:mmakempy.pdf|MakeMPY]]: create MetaPost outlines (by Pragma)
 +
* [[Flow Charts|FlowCharts]]: encapsulated application, demonstration of MetaPost/MetaFun
 
* [http://www.pragma-ade.com/general/sources/mptopdf.pdf MPtoPDF]: create PDF from MetaPost (by Pragma)
 
* [http://www.pragma-ade.com/general/sources/mptopdf.pdf MPtoPDF]: create PDF from MetaPost (by Pragma)
 
* [http://www.pragma-ade.com/show-gra.pdf a few examples of MetaPost graphics]
 
* [http://www.pragma-ade.com/show-gra.pdf a few examples of MetaPost graphics]
Line 59: Line 36:
 
* [http://www.ntg.nl/maps/25/15.pdf metapost metafun. Hans Hagen at MAPS]
 
* [http://www.ntg.nl/maps/25/15.pdf metapost metafun. Hans Hagen at MAPS]
  
==Examples==
 
 
* An encapsulated application of MetaPost/MetaFun is the [[Flow Charts|FlowCharts]] module
 
  
 +
----
 
[[Category:Graphics]]
 
[[Category:Graphics]]
 
[[Category:Metapost]]
 
[[Category:Metapost]]
  
  
 +
{{MetaPost see also}}
 
{{Metapost navbox}}
 
{{Metapost navbox}}

Revision as of 21:49, 6 June 2020


MetaFun is ConTeXt extension the MetaPost language. It provides a tight integration of both TeX and MetaPost. MetaPost can used behind the scenes for some graphic trickery. This integration is also helpful for drawing figures in MetaPost and use them in the document.

THE MetaFun manual, also available in a screen version.


This page is a brief overview of some of the commonly used commands.


Commonly used commands

\defineMPinstance, \setupMPinstance
used to set up MetaPost invocations with particular features. One use case could be to select a sans serif font for all MetaPost labels.
\startMPenvironment is DEPRECATED in which one could place settings that one only wanted to apply in the MetaPost environment, but not in the document itself. One should use \defineMPinstance and \setupMPinstance, instead.
\startMPinclusions
Inside, one can specify MetaPost files to input, and also define MetaPost functions.
\startuseMPgraphic, \useMPgraphic
defines a piece of graphics code that is processed anew every time the graphic is placed with \useMPgraphic.
\startreusableMPgraphic, \reuseMPgraphic
For graphics that are the same every time, it is better to use \startreusableMPgraphic: the graphic is compiled only once, and the one resulting picture can be placed at various points with \reuseMPgraphic.
\startMPcode
When reusing a graphic is not important, you can simply use \startMPcode.
\startMPpage
produces a page a containing MetaPost graphic. The page is just large enough to contain the graphic. The resulting pdf is self-contained (it has all the fonts embedded). This is useful if you want to send the figure to a coauthor or a journal.
\startstaticMPfigure, \usestaticMPfigure
The \startuseMPgraphic series of commands were designed for using MetaPost for drawing fancy frames and backgrounds and not for using stand-alone graphics for a document. \startstaticMPfigure creates a separate pdf file containing the graphic. This pdf can be included in the document using \usestaticMPfigure. ConTeXt is clever enough to recompile the resulting MetaPost file only if something inside the \startstaticMPfigure has changed.

Documentation and links