Hi,

Le 21 juill. 2021 à 10:08, Jeroen <contextntg@gmail.com> a écrit :

I use this small animation to enlarge a circle


\usemodule[animation]
\setupinteraction[state=start]
\starttext
\startanimation[menu=yes,framerate=10]
\dorecurse{7}{\expanded
  {\startframe
    \startMPcode
    path p;
    numeric n, u;
    u := 1cm;
    n:=\recurselevel*u;
    p := fullcircle scaled n;
    draw p;
    \stopMPcode
  \stopframe}}
\stopanimation
\stoptext


This I use to draw a sine


\starttext
\startMPcode
  draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. (i/360*1.5cm,0.9cm*(sind(i)))endfor;
\stopMPcode
\stoptext


When I put it together to animate the sine as following, it does not entirely create the sine animation I am looking for


\usemodule[animation]
\setupinteraction[state=start]
\starttext
\startanimation[menu=yes,framerate=10]
\dorecurse{7}{\expanded
  {\startframe
    \startMPcode
    path p;
    numeric n, u;
    u := 1cm;
    n:=\recurselevel*u;
    p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
    draw p;
    \stopMPcode
    \stopframe}}
\stopanimation
\stoptext


What better way can I create a sine animation with Metapost?

 



Here is another way to do your animation. This is doing something, but I guess not what you want. Could you describe what do you have in mind ?

\starttext
\dorecurse{7}{ % 3180
\startMPpage
myvariable := #1 ;
path p;
    numeric n, u;
    u := 1cm;
    n:=myvariable*u;
    p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
    draw p;
\stopMPpage
}
\stoptext

Fabrice.