* Re: \startanimation and \dorecurse
[not found] <mailman.168.1413928889.2277.ntg-context@ntg.nl>
@ 2014-10-22 8:01 ` Jeong Dal
0 siblings, 0 replies; 5+ messages in thread
From: Jeong Dal @ 2014-10-22 8:01 UTC (permalink / raw)
To: ntg-context
Dear Wolfgang,
According to your advice, I am able to make a working example as following.
\usemodule[animation]
\setupinteraction[state=start]
\startuseMPgraphic{Circles}{s}
numeric sn, L, N;
path p, q;
p := fullcircle scaled 72;
L:=length p;
N:=20;
sn := \MPvar{s};
q := subpath (0, sn/N*L) of p;%
draw q withcolor red;
fill fullcircle scaled 3 shifted point length q of q withcolor blue;
setbounds currentpicture to unitsquare shifted (-0.5,-0.5) scaled 75;
\stopuseMPgraphic
\starttext
\startanimation[menu=yes, menucolor=blue, framerate=5]
\dorecurse{20}
{\expanded{\frame{
\useMPgraphic{Circles}{s=\recurselevel}}}}
\stopanimation
\stoptext
One more question.
In metafun document, there is a command \setupMPvariables before \startuseMPgraphic. But we don’t use it in this example.
Hence I think that it is not necessary always. Is there any case in which we have set the MPvariables?
Thank you.
Best regards,
Dalyoung
___________________________________________________________________________________
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] 5+ messages in thread
[parent not found: <mailman.161.1413864303.2277.ntg-context@ntg.nl>]
* Re: \startanimation and \dorecurse
[not found] <mailman.161.1413864303.2277.ntg-context@ntg.nl>
@ 2014-10-21 12:08 ` Jeong Dal
2014-10-21 13:09 ` Wolfgang Schuster
0 siblings, 1 reply; 5+ messages in thread
From: Jeong Dal @ 2014-10-21 12:08 UTC (permalink / raw)
To: ntg-context
Dear Wolfgang,
Thank you for a nice solution.
I applied your method to produce an animation which draw a circle using the following:
%%%%%%%%
\usemodule[animation]
\setupinteraction[state=start]
\startuseMPgraphic{Circles}{s}
numeric sn, L, N;
path p, q;
p := fullcircle scaled 72;
L:=length p;
N:=20;
sn:= \MPvar{s};
q := subpath (0, sn/N*L) of p;%
draw q withcolor red;
fill fullcircle scaled 3 shifted point length q of q withcolor blue;
setbounds currentpicture to unitsquare shifted (-0.5,-0.5) scaled 75;
\stopuseMPgraphic
\starttext
\startanimation
\dorecurse{20}
{\startexpanded
%\setupMPvariables[Circles][s]
\useMPgraphic{Circles}{s=\recurselevel}
\stopexpanded}
\stopanimation
\stoptext
%%%%%%%%%%
However, it just draw 20 figures instead of making an animation.
Would you please tell me what is wrong in the above code?
Thank you.
Best regards,
Dalyoung
___________________________________________________________________________________
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] 5+ messages in thread
* Re: \startanimation and \dorecurse
2014-10-21 12:08 ` Jeong Dal
@ 2014-10-21 13:09 ` Wolfgang Schuster
0 siblings, 0 replies; 5+ messages in thread
From: Wolfgang Schuster @ 2014-10-21 13:09 UTC (permalink / raw)
To: mailing list for ConTeXt users
> Am 21.10.2014 um 14:08 schrieb Jeong Dal <haksan@me.com>:
>
> Dear Wolfgang,
>
> Thank you for a nice solution.
>
> I applied your method to produce an animation which draw a circle using the following:
>
> %%%%%%%%
> \usemodule[animation]
> \setupinteraction[state=start]
> \startuseMPgraphic{Circles}{s}
> numeric sn, L, N;
> path p, q;
> p := fullcircle scaled 72;
> L:=length p;
> N:=20;
> sn:= \MPvar{s};
> q := subpath (0, sn/N*L) of p;%
> draw q withcolor red;
> fill fullcircle scaled 3 shifted point length q of q withcolor blue;
> setbounds currentpicture to unitsquare shifted (-0.5,-0.5) scaled 75;
> \stopuseMPgraphic
> \starttext
> \startanimation
> \dorecurse{20}
> {\startexpanded
> %\setupMPvariables[Circles][s]
> \useMPgraphic{Circles}{s=\recurselevel}
> \stopexpanded}
> \stopanimation
> \stoptext
> %%%%%%%%%%
>
> However, it just draw 20 figures instead of making an animation.
>
> Would you please tell me what is wrong in the above code?
You have to put each meatiest graphic into a frame, there are three ways to create a frame.
1. Use braces around the frame
\startanimation
{First frame}
{Second frame}
{Third frame}
\stopanimation
This method doesn’t work in your case where you use \dorecurse to create the graphics.
2. Use the \frame command.
\startanimation
\frame{First frame}
\frame{Second frame}
\frame{Third frame}
\stopanimation
In this case the \frame command is used store the content for each frame, this can be used
when you create all frames with a loop like in your case, e.g.
\dorecurse{10}{\expanded{\frame{\useMPPgraphic{…}{var=\recurselevel}}}}
3. Use the \startframe environment.
\startanimation
\startframe First frame \stopframe
\startframe Second frame \stopframe
\startframe Third frame \stopframe
\stopaniamtion
This is the same as the second method except that you use star/stop delimiters
for each frame content instead of putting it into a argument.
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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
* \startanimation and \dorecurse
@ 2014-10-20 11:32 Jeong Dal
2014-10-20 11:54 ` Wolfgang Schuster
0 siblings, 1 reply; 5+ messages in thread
From: Jeong Dal @ 2014-10-20 11:32 UTC (permalink / raw)
To: ntg-context
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.
Best regards,
Dalyoung
___________________________________________________________________________________
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] 5+ messages in thread
* Re: \startanimation and \dorecurse
2014-10-20 11:32 Jeong Dal
@ 2014-10-20 11:54 ` Wolfgang Schuster
0 siblings, 0 replies; 5+ messages in thread
From: Wolfgang Schuster @ 2014-10-20 11:54 UTC (permalink / raw)
To: mailing list for ConTeXt users
> 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
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-10-22 8:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <mailman.168.1413928889.2277.ntg-context@ntg.nl>
2014-10-22 8:01 ` \startanimation and \dorecurse Jeong Dal
[not found] <mailman.161.1413864303.2277.ntg-context@ntg.nl>
2014-10-21 12:08 ` Jeong Dal
2014-10-21 13:09 ` Wolfgang Schuster
2014-10-20 11:32 Jeong Dal
2014-10-20 11:54 ` Wolfgang Schuster
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).