Re: [NTG-context] MetaPost Animations

2012-12-30 Thread Mojca Miklavec
On Sun, Dec 30, 2012 at 3:57 AM, Troy Henderson wrote:
 Bonus question: independent from the gears shape (assume that it stays
 as it is), there is something fundamentally wrong with the animation.
 What is that? ;)


 When fixing the teeth, I broke the direction of one of the gears.  It's
 repaired now.

Yes, it makes more sense now.

Very nice animations.

Mojca
___
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
___


Re: [NTG-context] MetaPost Animations

2012-12-30 Thread Jeong Dal
Dear Troy,

The animations are impressive and thank you for sharing the code.

In the creation of many pdf for animation, it changes the recurselevel only.
 I wonder if there is a way to make such kind of animation in ConTeXt using 
Wolfgang's animation module.
Then we can include the animation in PDF output directly.

Here is my trial.

I modified it as following and got an animation. But it is only good for a few 
step animation.

%
\startbuffer[base]
N:=64;%\N;
u:=136;
pair f;
c:=2/(1+sqrt(5));%\c;
if c1: f:=(1+-+c,0); v:=u/2; else: f:=(0,1+-+(1/c)); v:=u/c/2; fi; % Focus f 
is defined
path p,q;
pair z;
picture base;
numeric L;
p:=fullcircle yscaled c; % This is the ellipse
L:=length p;
draw p scaled (2*v) withpen pencircle scaled (v/260) dashed evenly; % Draw the 
ellipse dashed (will be traced later)
base:= currentpicture;
q:=bbox currentpicture enlarged (v/64); % Enlarge the bounding box slightly
q:=(llcorner q+(-v/128,-v/128))--(lrcorner q+(v/128,-v/128))--(urcorner 
q+(v/128,v/128))--(urcorner q+(-v/128,v/128))--cycle;
fill fullcircle scaled (v/32) shifted (f*v) withcolor red; % Focus
fill fullcircle scaled (v/32) shifted (-f*v) withcolor red; % Focus
base:=currentpicture; % Save this picture to draw in every frame
setbounds currentpicture to q; % Set the bounding box as described before
\stopbuffer

\startbuffer[fig1]
%\startMPpage
n:=1;%\recurselevel%1;
draw base; % Draw the common picture saved above
draw subpath (0,(n-1)/(N-1)*L) of p scaled (2*v) withpen pencircle scaled 
(v/130) withcolor blue; % Trace the ellipse in blue
z:=point ((n-1)/(N-1)*L) of p scaled v; % The point on the ellipse where we are 
thusfar
fill fullcircle scaled (v/32) shifted (2*z) withcolor blue; % Draw the point
draw (-f*v)--(2*z)--(f*v) withpen pencircle scaled (v/260); % Draw the string 
used to trace the ellipse
setbounds currentpicture to q; % Set the bounding box so that it is the same 
for each frame
%\stopMPpage
\stopbuffer

\startbuffer[fig2]
%\startMPpage
n:=2;
draw base; % Draw the common picture saved above
draw subpath (0,(n-1)/(N-1)*L) of p scaled (2*v) withpen pencircle scaled 
(v/130) withcolor blue; % Trace the ellipse in blue
z:=point ((n-1)/(N-1)*L) of p scaled v; % The point on the ellipse where we are 
thusfar
fill fullcircle scaled (v/32) shifted (2*z) withcolor blue; % Draw the point
draw (-f*v)--(2*z)--(f*v) withpen pencircle scaled (v/260); % Draw the string 
used to trace the ellipse
setbounds currentpicture to q; % Set the bounding box so that it is the same 
for each frame
%\stopMPpage
\stopbuffer

\startbuffer[fig3]
%\startMPpage
n:=3;
draw base; % Draw the common picture saved above
draw subpath (0,(n-1)/(N-1)*L) of p scaled (2*v) withpen pencircle scaled 
(v/130) withcolor blue; % Trace the ellipse in blue
z:=point ((n-1)/(N-1)*L) of p scaled v; % The point on the ellipse where we are 
thusfar
fill fullcircle scaled (v/32) shifted (2*z) withcolor blue; % Draw the point
draw (-f*v)--(2*z)--(f*v) withpen pencircle scaled (v/260); % Draw the string 
used to trace the ellipse
setbounds currentpicture to q; % Set the bounding box so that it is the same 
for each frame
%\stopMPpage
\stopbuffer

\setupinteraction[state=start]
\usemodule[animation]
\starttext
\startanimation[menu=yes]

{\processMPbuffer[base, fig1]}
{\processMPbuffer[base, fig2]}
{\processMPbuffer[base, fig3]}
\stopanimation
\stoptext

%

I also tried to simplify the code as following, but it just draw 10 figures not 
an animation.
Is there a way to combine them as an animation?

Thank you.

Best regards,

Dalyoung
 
%
\startbuffer[base]
N:=64;%\N;
u:=136;
pair f;
c:=2/(1+sqrt(5));%\c;
if c1: f:=(1+-+c,0); v:=u/2; else: f:=(0,1+-+(1/c)); v:=u/c/2; fi; % Focus f 
is defined
path p,q;
pair z;
picture base;
numeric L;
p:=fullcircle yscaled c; % This is the ellipse
L:=length p;
draw p scaled (2*v) withpen pencircle scaled (v/260) dashed evenly; % Draw the 
ellipse dashed (will be traced later)
base:= currentpicture;
q:=bbox currentpicture enlarged (v/64); % Enlarge the bounding box slightly
q:=(llcorner q+(-v/128,-v/128))--(lrcorner q+(v/128,-v/128))--(urcorner 
q+(v/128,v/128))--(urcorner q+(-v/128,v/128))--cycle;
fill fullcircle scaled (v/32) shifted (f*v) withcolor red; % Focus
fill fullcircle scaled (v/32) shifted (-f*v) withcolor red; % Focus
base:=currentpicture; % Save this picture to draw in every frame
setbounds currentpicture to q; % Set the bounding box as described before
\stopbuffer

\startbuffer[fig1]
%\startMPpage
n:=\recurselevel;
draw base; % Draw the common picture saved above
draw subpath (0,(n-1)/(N-1)*L) of p scaled (2*v) withpen pencircle scaled 
(v/130) withcolor blue; % Trace the ellipse in blue
z:=point ((n-1)/(N-1)*L) of p scaled v; % The point on the ellipse where we are 
thusfar
fill fullcircle scaled (v/32) shifted (2*z) withcolor blue; % Draw the point
draw (-f*v)--(2*z)--(f*v) withpen pencircle scaled 

Re: [NTG-context] MetaPost Animations

2012-12-30 Thread Wolfgang Schuster

Am 30.12.2012 um 14:19 schrieb Jeong Dal hak...@me.com:

 Dear Troy,
 
 The animations are impressive and thank you for sharing the code.
 
 In the creation of many pdf for animation, it changes the recurselevel only.
 I wonder if there is a way to make such kind of animation in ConTeXt using 
 Wolfgang's animation module.
 Then we can include the animation in PDF output directly.
 
 Here is my trial.
 
 I modified it as following and got an animation. But it is only good for a 
 few step animation.
 
 […]
 
 I also tried to simplify the code as following, but it just draw 10 figures 
 not an animation.
 Is there a way to combine them as an animation?

You can use a loop to create the frames, the only thing you have to be aware is
how to access the counter loop iteration. In most cases you can get the current
iteration of the loop with \recurselevel but this doesn’t work for animation 
because
each frame is saved in a symbol with \definesymbol[frame][code] without
expanding the content.

To fix this you can expand the content with \expanded{\frame{… \recurselevel …}}
or simpler by using “#1” instead of \recurselevel to access the counter.

The braces around each frame as in your example are only one method to set
the content for each frame (it emulates the \startoverlay and \startcombination
input), when you use a loop you have to use \frame{…} or \startframe … 
\stopframe
to set the content for each frame.


Example:

\usemodule[animation]

\setupinteraction[state=start]

\starttext

\startanimation[menu=yes,framerate=10]
\dorecurse{99}
  {\startframe
   \definedfont[Mono sa 4]\twodigits{#1}%
   \stopframe}
\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
___