On Sun, 19 Apr 2020, Jeong Dal wrote:

Dear all,

I am trying to make an animation using the animation module.
But it draws 10 figures instead of creating animation.
Is there anything I have to do more?
Or, is there a better way to do this?

Thank you for reading.

Best regards,

Dalyoung


\startuseMPgraphic{inversionPoint}{n}
vardef findPointD(expr C, Q, r) =
   numeric dist, ang;
   pair X, Y;
   dist := r**2/sqrt((xpart Q - xpart C)**2 + (ypart Q - ypart C)**2);
   ang := angle(Q - C);
   Y := C + dir(ang)*dist;
   Y
enddef;
numeric radius, now, move;
pair A,B,C,P,Q;
path p,q;

radius := 2cm;
C := origin;
p := fullcircle scaled (2*radius);
z[1] = point 6 of p;
z[2] = point .8 of p;

q := (1.5*z1 - .5*z2) -- (-.5z1 + 1.5*z2);
%q := fullcircle scaled radius shifted (2cm, 1cm);
draw p;
draw q;
%for i := 0 step 0.1 until 1:
   move := 0.1;
   now := move*\MPvar{n};
   P := point now along q;
   Q := findPointD(C, P, radius);
   drawdot P;
   drawdot Q withcolor .625red;
   dotlabel.lft(textext("P"),P);
   dotlabel.rt(textext("Q"),Q) withcolor .625red;
%endfor;
\stopuseMPgraphic

\usemodule[animation]
\setupinteraction[state=start]

\starttext
%\startplacefigure[]
   \startanimation[menu=yes]
   \dorecurse{10}{
   \useMPgraphic{inversionPoint}{n=\recurselevel}
   }
   \stopanimation
%\stopplacefigure
\stoptext

Also see my simple wrapper around this:

https://adityam.github.io/context-blog/post/metapost-animation/

Aditya
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to