![](https://secure.gravatar.com/avatar/d39338246f50cca667c8256c313d7cfd.jpg?s=120&d=mm&r=g)
Hi, in one of the last few betas the MetaPost instance mechanism broke. \defineMPinstance [myinstance] [metafun] \startuseMPgraphic{mympgraphic} fill fullsquare scaled 1cm withcolor blue; \stopuseMPgraphic \starttext\null \useMPgraphic{myinstance::mympgraphic} \stoptext Marco
![](https://secure.gravatar.com/avatar/27c34cb91f1e92bd850fe60b3d9ef336.jpg?s=120&d=mm&r=g)
Am 25.11.2012 um 18:11 schrieb Marco Patzer
Hi,
in one of the last few betas the MetaPost instance mechanism broke.
\defineMPinstance [myinstance] [metafun]
\startuseMPgraphic{mympgraphic} fill fullsquare scaled 1cm withcolor blue; \stopuseMPgraphic
\starttext\null \useMPgraphic{myinstance::mympgraphic} \stoptext
The problem lies in the \uniqueMPgraphic and \useMPgrpahic commands. There is a commented line in each command which is the correct setting and the next line is wrong. \def\meta_unique_page_graphic#1#2% {\meta_begin_graphic_group{#1}% \let\overlaystamp\overlaypagestamp \setupMPvariables[\m_meta_page_prefix:\currentMPgraphicname][#2]% prefix is new here % \getvalue{\??mpgraphic\m_meta_page_prefix:\currentMPgraphicname}{}% \getvalue{\??mpgraphic\m_meta_page_prefix:#1}{}% \meta_end_graphic_group} \def\meta_use_graphic#1#2% {\meta_begin_graphic_group{#1}% \doifsomething{#2}{\setupMPvariables[\currentMPgraphicname][#2]}% %\getvalue{\??mpgraphic\currentMPgraphicname}\empty \getvalue{\??mpgraphic#1}\empty \meta_end_graphic_group} Wolfgang
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
On Sun, 25 Nov 2012, Marco Patzer wrote:
Hi,
in one of the last few betas the MetaPost instance mechanism broke.
\defineMPinstance [myinstance] [metafun]
\startuseMPgraphic{mympgraphic} fill fullsquare scaled 1cm withcolor blue; \stopuseMPgraphic
\starttext\null \useMPgraphic{myinstance::mympgraphic} \stoptext
I am still using the old 2012.11.16 version, but now you have to specify the instance in the \startuseMPgraphic as well (Hans had announced this on the mailing list a few weeks ago): \startuseMPgraphic{instance::mygraphic} ... \stopuseMPgraphic Aditya
![](https://secure.gravatar.com/avatar/d39338246f50cca667c8256c313d7cfd.jpg?s=120&d=mm&r=g)
2012-11-25 Aditya Mahajan:
I am still using the old 2012.11.16 version, but now you have to specify the instance in the \startuseMPgraphic as well (Hans had announced this on the mailing list a few weeks ago):
I missed that.
\startuseMPgraphic{instance::mygraphic} ... \stopuseMPgraphic
This works. Thanks to both of you, Wolfgang and Aditya. Marco
![](https://secure.gravatar.com/avatar/1930c667fbd3884fd581e95eb4d5b15c.jpg?s=120&d=mm&r=g)
Aditya wrote:
I am still using the old 2012.11.16 version, but now you have to specify the instance in the \startuseMPgraphic as well (Hans had announced this on the mailing list a few weeks ago): \startuseMPgraphic{instance::mygraphic} ... \stopuseMPgraphic
Since I don't use MetaPost, I don't think I'm the best person to document this. But I took this as an opportunity to create the command reference pages for a bunch of the \...MP... commands; perhaps one of you could add this info to the proper page(s)? E.g. at http://wiki.contextgarden.net/Command/startuseMPgraphic There is an overview of the new stubs at http://wiki.contextgarden.net/Template:MetaPost_see_also Also: a question about \startuseMPgraphic and \startuniqueMPgraphic. Both are supposed to be recompiled at every usage, so how are they different? Actually trying it out suggests that useMPgraphic is the only one of the two that re-evaluates its code every time; compare the examples at * http://wiki.contextgarden.net/Command/startuseMPgraphic and * http://wiki.contextgarden.net/Command/startuniqueMPgraphic But then \startuniqueMPgraphic would be the same as \startreuseMPgraphic, so I think I'm still missing something. Cheers, Sietse
![](https://secure.gravatar.com/avatar/d39338246f50cca667c8256c313d7cfd.jpg?s=120&d=mm&r=g)
2012-11-26 Sietse Brouwer:
Since I don't use MetaPost, I don't think I'm the best person to document this. But I took this as an opportunity to create the command reference pages for a bunch of the \...MP... commands; perhaps one of you could add this info to the proper page(s)?
Thanks. I added some info about the change mentioned in this thread.
Also: a question about \startuseMPgraphic and \startuniqueMPgraphic. Both are supposed to be recompiled at every usage, so how are they different? Actually trying it out suggests that useMPgraphic is the only one of the two that re-evaluates its code every time; compare the examples at
AFAIK useMPgraphic is always recalculated, reusableMPgraphic never is. uniqueMPgraphic takes the size into account and recalculates if the graphic dimensions change. If I recall correctly this is mentioned somewhere in the MetaFun manual. But I agree, all these commands for including MP graphics are confusing, given the fact that one can survive pretty well with only useMPgraphic. I attached a small example to show the difference. Marco
![](https://secure.gravatar.com/avatar/c5ae4f9aa0d3a9bd5376e92b322c3e50.jpg?s=120&d=mm&r=g)
On Mon, 26 Nov 2012, Marco Patzer wrote:
2012-11-26 Sietse Brouwer:
Since I don't use MetaPost, I don't think I'm the best person to document this. But I took this as an opportunity to create the command reference pages for a bunch of the \...MP... commands; perhaps one of you could add this info to the proper page(s)?
Thanks. I added some info about the change mentioned in this thread.
Also: a question about \startuseMPgraphic and \startuniqueMPgraphic. Both are supposed to be recompiled at every usage, so how are they different? Actually trying it out suggests that useMPgraphic is the only one of the two that re-evaluates its code every time; compare the examples at
AFAIK useMPgraphic is always recalculated, reusableMPgraphic never is. uniqueMPgraphic takes the size into account and recalculates if the graphic dimensions change. If I recall correctly this is mentioned somewhere in the MetaFun manual. But I agree, all these commands for including MP graphics are confusing, given the fact that one can survive pretty well with only useMPgraphic. I attached a small example to show the difference.
The distinction was more important in MkII when extra runs for different MP graphics could take a lot of time. But it MkIV, the difference in performance is, I believe, inconsequential. Aditya
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
On 11/26/2012 5:10 PM, Marco Patzer wrote:
2012-11-26 Sietse Brouwer:
Since I don't use MetaPost, I don't think I'm the best person to document this. But I took this as an opportunity to create the command reference pages for a bunch of the \...MP... commands; perhaps one of you could add this info to the proper page(s)?
Thanks. I added some info about the change mentioned in this thread.
Also: a question about \startuseMPgraphic and \startuniqueMPgraphic. Both are supposed to be recompiled at every usage, so how are they different? Actually trying it out suggests that useMPgraphic is the only one of the two that re-evaluates its code every time; compare the examples at
AFAIK useMPgraphic is always recalculated, reusableMPgraphic never is. uniqueMPgraphic takes the size into account and recalculates if the graphic dimensions change. If I recall correctly this is
Can be more than dimensions. This is the default hash: \def\overlaystamp {\overlaywidth :% \overlayheight:% \overlaydepth :% \MPcolor\overlaycolor:% \MPcolor\overlaylinecolor} so: width, height, depth, background color, line color but is one says \startuniqueMPgraphic{mygraphic}{linewidth,.....} given that linewidth is set, those values are also taken into account
mentioned somewhere in the MetaFun manual. But I agree, all these commands for including MP graphics are confusing, given the fact that one can survive pretty well with only useMPgraphic. I attached a small example to show the difference.
It does make a difference when you have documents with thousands of graphics (mkiv is much faster btw) and the pdf file is also smaller when reuse is applied Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/d39338246f50cca667c8256c313d7cfd.jpg?s=120&d=mm&r=g)
On 2012–11–25 Marco Patzer wrote:
in one of the last few betas the MetaPost instance mechanism broke.
Did the interface change again? The following does not work on today's beta, only “alpha” and “gamma” are printed. \defineMPinstance [myinstance] [metafun] \startuseMPgraphic{alpha} draw textext("alpha") ; \stopuseMPgraphic \startuseMPgraphic{myinstance::beta} draw textext("beta") ; \stopuseMPgraphic \starttext \useMPgraphic{alpha} \useMPgraphic{myinstance::beta} \startMPcode{myinstance} draw textext("gamma") ; \stopMPcode \stoptext Marco
![](https://secure.gravatar.com/avatar/49e63acb01f2ca80efce7eed08310ce8.jpg?s=120&d=mm&r=g)
On 12/6/2012 8:10 PM, Marco Patzer wrote:
On 2012–11–25 Marco Patzer wrote:
in one of the last few betas the MetaPost instance mechanism broke.
Did the interface change again? The following does not work on today's beta, only “alpha” and “gamma” are printed.
\defineMPinstance [myinstance] [metafun]
\startuseMPgraphic{alpha} draw textext("alpha") ; \stopuseMPgraphic
\startuseMPgraphic{myinstance::beta} draw textext("beta") ; \stopuseMPgraphic
\starttext \useMPgraphic{alpha} \useMPgraphic{myinstance::beta} \startMPcode{myinstance} draw textext("gamma") ; \stopMPcode \stoptext
sure, we have a different interface on odd days Currently instances are played with a bit (as Alan and I want the chemical module to run in its own but also want it to be public). Anyhow, one complication is in the related variables. I now have a version that supports this: \defineMPinstance [myinstance] [metafun] \startuseMPgraphic{alpha} draw textext("alpha") ; \stopuseMPgraphic \startuseMPgraphic{myinstance::beta} draw textext("beta") ; \stopuseMPgraphic \startuniqueMPgraphic{myinstance::beta}{width} draw textext("beta") xsized \MPvar{width} ; \stopuniqueMPgraphic \startuseMPgraphic{myinstance::epsilon}{width,height} draw textext("epsilon") xysized (\MPvar{width},\MPvar{height}) ; \stopuseMPgraphic \setMPvariables [myinstance::beta] [width=5cm] \setMPvariables [epsilon] [width=5cm, height=5cm] \starttext one : \useMPgraphic{alpha} \blank two : \useMPgraphic{myinstance::beta} \blank three : \startMPcode{myinstance} draw textext("gamma") ; \stopMPcode \blank four : \reuseMPgraphic{myinstance::beta}{width=2cm} \blank five : \startMPcode{myinstance} draw textext("delta") ; \stopMPcode \blank six : \reuseMPgraphic{myinstance::epsilon}{height=2cm} \blank seven : \reuseMPgraphic{myinstance::epsilon} \blank \stoptext Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
participants (5)
-
Aditya Mahajan
-
Hans Hagen
-
Marco Patzer
-
Sietse Brouwer
-
Wolfgang Schuster