ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Wolfgang Schuster <schuster.wolfgang@gmail.com>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: \startanimation and \dorecurse
Date: Mon, 20 Oct 2014 13:54:44 +0200	[thread overview]
Message-ID: <75B477B5-F729-4AA0-B439-A15A05328328@gmail.com> (raw)
In-Reply-To: <FC6ECFB2-8DB0-47F6-93F9-D6CDE593EEAA@me.com>


> Am 20.10.2014 um 13:32 schrieb Jeong Dal <haksan@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
___________________________________________________________________________________
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
___________________________________________________________________________________

  reply	other threads:[~2014-10-20 11:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-20 11:32 Jeong Dal
2014-10-20 11:54 ` Wolfgang Schuster [this message]
     [not found] <mailman.161.1413864303.2277.ntg-context@ntg.nl>
2014-10-21 12:08 ` Jeong Dal
2014-10-21 13:09   ` Wolfgang Schuster
     [not found] <mailman.168.1413928889.2277.ntg-context@ntg.nl>
2014-10-22  8:01 ` Jeong Dal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=75B477B5-F729-4AA0-B439-A15A05328328@gmail.com \
    --to=schuster.wolfgang@gmail.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).