// Un ancien exemple de Ph. Ivaldi import animate; settings.tex="pdflatex"; settings.outformat="pdf"; size(7cm); animation A; void koch(pair A, pair B, int n) { pair C; C=rotate(120, point(A--B,1/3))*A; if (n>0) { koch(A,point(A--B,1/3),n-1); koch(point(A--B,1/3),C,n-1); koch(C,point(A--B,2/3),n-1); koch(point(A--B,2/3),B,n-1); } else draw(A--point(A--B,1/3)--C--point(A--B,2/3)--B); } pair z0=(1,0); pair z1=rotate(120)*z0; pair z2=rotate(120)*z1; real pmax=4; for (int p=0; p<=pmax; p+=1) { save(); koch(z0,z1,p); koch(z1,z2,p); koch(z2,z0,p); A.add(); erase(); } A.movie(); // remplacer par la ligne suivante // label(A.pdf(BBox(1mm,nullpen),delay=500,"controls,loop")); // pour obtenir une animation dans une seule page d'un pdf. // controls : pour obtenir les boutons, // loop : pour que cela tourne en boucle par défaut.