[NTG-context] Using metapost figures in context
Aditya Mahajan
adityam at umich.edu
Wed Jun 14 17:00:49 CEST 2006
On Tue, 13 Jun 2006, Hans Hagen wrote:
> Aditya Mahajan wrote:
>> I have right now kept the command as MPfigure.
>>
> grep MPfigure in meta-fig -)
>
Now I am using staticMPfigure. This is the final version
\def\startstaticMPfigure#1#2\stopstaticMPfigure
{\bgroup
\setMPrandomseedfalse
%Otherwise randomseed := number line always differ
\doifmodeelse{*pdf}
{\def\executeMPTEX##1%
{texmfstart --verbose --ifchanged=##1.mp texexec --mpgraphic
##1.mp}
\let\executeMPOST=\executeMPTEX}
{\def\executeMPOST##1%
{texmfstart --verbose --ifchanged=##1.mp bin:mpost
\ifcase\interactionmode\MPOSTbatchswitch\or\MPOSTnonstopswitch\fi
\space\ifuseMETAFUNformat \MPOSTformatswitch metafun \fi ##1}
\def\executeMPTEX##1% slower, due to nested texexec call
{texmfstart --verbose --ifchanged=##1.mp texexec
--batch \ifcase\interactionmode --logfile='mptex.log' \fi
--output=\MPOSTdriver\space
\ifuseMETAFUNformat --mpformat=metafun \fi --mptex --nomp
--once ##1}}
\def\MPgraphicfile{\jobname-#1}
\newcount\currentMPgraphic
\startMPgraphic
#2
\stopMPgraphic\egroup\deallocateMPslot\currentMPgraphic}
\def\usestaticMPfigure{\dosingleempty\dousestaticMPfigure}
\def\dousestaticMPfigure[#1]%
{\doifmodeelse{*pdf}
{\externalfigure[\jobname-#1.pdf]}
{\externalfigure[\jobname-#1.1]}}
\starttext
\startstaticMPfigure{circle}
fill fullcircle scaled 10cm;
\stopstaticMPfigure
\startstaticMPfigure{axis}
drawarrow (0,0)--(1cm,0) ;
drawarrow (0,0)--(0,1cm) ;
label.llft(textext("(0,0)") ,origin) ;
\stopstaticMPfigure
\hbox to \hsize \bgroup
\hss \usestaticMPfigure[circle][width=1cm] \hss
\usestaticMPfigure[axis] \hss \egroup
\stoptext
Thanks,
Aditya
More information about the ntg-context
mailing list