ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* TeX macro to MP variable
@ 2013-03-16 15:07 Marco Patzer
  2013-03-16 15:37 ` Thomas A. Schmitz
  2013-03-16 21:46 ` Hans Hagen
  0 siblings, 2 replies; 10+ messages in thread
From: Marco Patzer @ 2013-03-16 15:07 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1055 bytes --]

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?

Marco

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-03-17 13:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-16 15:07 TeX macro to MP variable Marco Patzer
2013-03-16 15:37 ` Thomas A. Schmitz
2013-03-16 15:47   ` Marco Patzer
2013-03-16 16:13   ` Marco Patzer
2013-03-16 17:08     ` Wolfgang Schuster
2013-03-16 17:36       ` Marco Patzer
2013-03-17  0:11     ` Aditya Mahajan
2013-03-17 12:53       ` Marco Patzer
2013-03-16 21:46 ` Hans Hagen
2013-03-17 13:14   ` Marco Patzer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).