On 3/16/2013 4:07 PM, Marco Patzer wrote:
Hi,
I am looking for a way to assign the value of a TeX macro to an MP variable. However, this only works the first time, then the value is not updated any longer. Example:
\startMPdefinitions size = \somesize ; \stopMPdefinitions
\startuseMPgraphic{alpha} fill unitcircle scaled size; \stopuseMPgraphic
\starttext \def\somesize{1cm} \useMPgraphic{alpha} %% diameter = 1cm
\def\somesize{2cm} \useMPgraphic{alpha} %% diameter = 1cm \stoptext
I looked into \setupMPvariables, but I couldn't manage to assign them to an MP variable. The setups key from \defineMPinstance seems to to the job, but it's TeX, not MetaPost. What comes to mind is a \processMPbuffer before every MPgraphic:
\startbuffer[foo] size := \somesize ; \stopbuffer
\startuseMPgraphic{alpha} fill unitcircle scaled size; \stopuseMPgraphic
\starttext \def\somesize{1cm} \processMPbuffer[foo] \useMPgraphic{alpha} %% diameter = 1cm
\def\somesize{2cm} \processMPbuffer[foo] \useMPgraphic{alpha} %% diameter = 2cm \stoptext
Is there a better way?
grep for \includeMPgraphic -- ----------------------------------------------------------------- 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 -----------------------------------------------------------------