Animated GIF with EMT

I found the following animation on the nice blog WalkingRandomly. There it was done in Mathematica. I simply had to try that in EMT.

animate

The GIF files get large very soon, so you see only a tiny version. This one has 50 frames and 300×300 pixels. Maybe I missed some compression in the ImageMagic program I used to combine the files?

The code is easy and clean.

>function nicesave () ...
$  n=10; x=0:n; y=x'; r=0.5; m=50;
$  k=1;
$  for a=(0:m-1)/m*2pi;
$    d=a+(x+y)/n*2*pi;
$    plot2d(x+r*cos(d),y+r*sin(d),>points,<grid,style="o#");
$    savepng("file"+printf("%03g",k)+".png",300,300); k=k+1;
$    wait(0);
$  end;
$  exec("convert","file* animate.gif");
$  for k=1 to m; fileremove("file"+printf("%03g",k)+".png"); end;
$endfunction
>nicesave;
>exec("cmd","/c start animate.gif");

This saves the frames into files file001.png, file002.png etc. Then the external command „convert“ of ImageMagic combines the files.

If you do not want to save the animation, use the following.

>function nice () ...
$n=10; x=0:n; y=x'; r=0.5; m=100;
$repeat
$   k=1;
$   for a=(0:m-1)/m*2pi;
$   d=a+(x+y)/n*2*pi;
$   plot2d(x+r*cos(d),y+r*sin(d),>points,<grid,style="o#"); 
$   wait(0); 
$   end; 
$   until testkey(); 
$end; 
$endfunction 
>nice;

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.

Diese Website verwendet Akismet, um Spam zu reduzieren. Erfahre mehr darüber, wie deine Kommentardaten verarbeitet werden.