[NTG-context] \startanimation and \dorecurse

Wolfgang Schuster schuster.wolfgang at gmail.com
Mon Oct 20 13:54:44 CEST 2014


> Am 20.10.2014 um 13:32 schrieb Jeong Dal <haksan at me.com>:
> 
> Hi,
> 
> I tested the following simple code to generate enlarging circles as a test of animation.
> But it just draw 5 circles in a row.
> 
> \usemodule[animation]
> \setupinteraction[state=start]
> \startbuffer[Circles]
> numeric u; u:= 1cm;
> draw fullcircle scaled \MPrawvar{Circles}{s}u;
> \stopbuffer
> \starttext
> \startanimation
> { \dorecurse{5}{%
> \setupMPvariables[Circles][s=\recurselevel]
> \processMPbuffer [Circles]
> }}
> \stopanimation
> \stoptext
> 
> It seems to me that \startanimation just treat the figures 
> {\dorecurse … } as just one figure.
> 
> Is there a way to treat it 5 figures to generate animation? 
> 
> Thank you for reading.

1. You have to expand the \recurselevel value.

2. Don’t put braces around \dorecurse because when \startanimation sees a opening braces it assumes you want to put each frame into a group of braces.


Variant 1:

\usemodule[animation]

\setupinteraction[state=start]

\startbuffer[Circles]
numeric u; u:= 1cm;
draw fullcircle scaled \MPrawvar{Circles}{s}u;
\stopbuffer

\starttext

\startanimation
\dorecurse{5}
  {\startexpanded
     \startframe
       \setupMPvariables[Circles][s=\recurselevel]
       \processMPbuffer [Circles]
     \stopframe
   \stopexpanded}
\stopanimation

\stoptext


Variant 2:

\usemodule[animation]

\setupinteraction[state=start]

\startuseMPgraphic{Circles}{s}
numeric u; u:= 1cm;
draw fullcircle scaled \MPvar{s}u;
\stopuseMPgraphic

\starttext

\startanimation
\dorecurse{5}
  {\startexpanded
     \frame{\useMPgraphic{Circles}{s=\recurselevel}}%
   \stopexpanded}
\stopanimation

\stoptext

Wolfgang


More information about the ntg-context mailing list