When I create animations using MetaPost, I typically do something like for n=1 upto N: beginfig(n); <some code> endfig; endfor; and a sequence of figures are created. How can I do this in ConTeXt using \startMPpage ... \stopMPpage? Troy Henderson
On Sun, 9 Sep 2012, Troy Henderson wrote:
When I create animations using MetaPost, I typically do something like
for n=1 upto N: beginfig(n); <some code> endfig; endfor;
and a sequence of figures are created. How can I do this in ConTeXt using \startMPpage ... \stopMPpage?
(untested) \dorecurse{10} {\startMPpage label(btex On step \recurselevel etex, origin); \stopMPpage} (There is also \dostepwiserecurse if you need more control). Aditya
That works great. Now I have defined a global numeric N:=8; in \startMPinclusions ... \stopMPinclusions at the be beginning of my document. All of my \startMPpage ... \stopMPpage environments understand this N, but how do I reference this value as the start value for \dostepwiserecurse? That is, I would like to do something like \dostepwiserecurse{N}{0}{-1}{ ... <some code> ... } Troy
That works great. Now I have defined a global numeric
N:=8;
in \startMPinclusions ... \stopMPinclusions at the be beginning of my document. All of my \startMPpage ... \stopMPpage environments understand this N, but how do I reference this value as the start value for \dostepwiserecurse? That is, I would like to do something like
\dostepwiserecurse{N}{0}{-1}{ ... <some code> ... }
For that, you'll need to work on the TeX end. \edef\STEPS{8} \dorecurse\STEPS{....} You can either use \STEPS instead of N everywhere in your code (and be careful on how TeX code is parsed, i.e., `a := \STEPS 0` will evaluate to `a := 80`), or use `N := \STEPS;` somewhere in the beginning of each `\MPpage` (the `N :\ \STEPS` can be hidden behind a macro like `\initializeAnimation`). Aditya
That works great too. One more question now. I would like a particular MetaPost label to contain the value of a variable, say n. I don't want to use label(decimal(n),origin); because I want the label to be a TeX picture instead of a string. That is, I would like to have label(btex n etex,origin); where n is the VALUE of n and not the letter n. Thanks, Troy
participants (2)
-
Aditya Mahajan
-
Troy Henderson