Difference between revisions of "Command/defineMPinstance"

From Wiki
Jump to navigation Jump to search
(Add info about MPinstance separated by double-colon)
Line 25: Line 25:
  
 
== Description ==  
 
== Description ==  
This command sets up a custom MetaPost style with particular features that can be selected using the first argument. The instance <code>metafun</code> is the default one and does not need to be created. However, custom styles can inherit from the <code>metafun</code> instance.
+
This command sets up a custom MetaPost style with particular features that can be selected using the first argument. The instance <code>metafun</code> is the default one and does not need to be created. Custom styles can inherit from the <code>metafun</code> instance, or not.
  
The MetaPost instance is provided as first argument to <code>\startMPcode</code> or <code>\startuseMPgraphic</code>. In the latter case the figure name is separated by a double-colon from the instance name.
+
The MetaPost instance to use is specified as follows:
 +
* {{cmd|startMPcode}}.
 +
* {{cmd|useMPgraphic|{instancename::graphicname}|}}
 +
* {{cmd|startuseMPgraphic|{instancename::graphicname|}}{{since|2012|nov 2012}}
 +
* {{cmd|startuseMPgraphic|{graphicname}|}}{{Until|2012|nov 2012}}
 +
or {{cmd|startuseMPgraphic}}. In the latter case the figure name is separated by a double-colon from the instance name.{{since|2012|nov 2012}} Before november 2012
  
 
== Predefined Instances ==
 
== Predefined Instances ==
Line 65: Line 70:
 
\stopMPcode
 
\stopMPcode
  
 +
% a graphic that uses a custom instance
 +
% This
 
\startuseMPgraphic{veryimportant::mygraphic}
 
\startuseMPgraphic{veryimportant::mygraphic}
 
   draw textext("some text") ;
 
   draw textext("some text") ;

Revision as of 17:20, 26 November 2012

\defineMPinstance

Syntax

\defineMPinstance[...][...][...]
[...] name
[...] name for inheritance (optional)
[...] see \setupMPinstance


Description

This command sets up a custom MetaPost style with particular features that can be selected using the first argument. The instance metafun is the default one and does not need to be created. Custom styles can inherit from the metafun instance, or not.

The MetaPost instance to use is specified as follows:

or \startuseMPgraphic. In the latter case the figure name is separated by a double-colon from the instance name.Template:since Before november 2012

Predefined Instances

\defineMPinstance [metafun]  [format=metafun, extensions=yes, initializations=yes]
\defineMPinstance [metapost] [format=mpost]

Example

\defineMPinstance
  [important]
  [metafun] % needs to be inherited from the global metafun instance
  [textcolor=red]

\defineMPinstance
  [veryimportant]
  [important]
  [textstyle=bold]

\starttext

% normal black text
\startMPcode
  draw textext("some text") ;
\stopMPcode

% red text
\startMPcode{important}
  draw textext("some text") ;
\stopMPcode

% red bold text
\startMPcode{veryimportant}
  draw textext("some text") ;
\stopMPcode

% a graphic that uses a custom instance
% This 
\startuseMPgraphic{veryimportant::mygraphic}
  draw textext("some text") ;
\stopuseMPgraphic

\useMPgraphic{veryimportant::mygraphic}

\stoptext

Gives:


See also

Help from ConTeXt-Mailinglist/Forum

All issues with: