Une fonction artisanale écrite en processing pour dessiner un astroïde.
Attention, pas « astéroïde » (objet céleste) mais bien « astroïde » (figure géométrique en forme d’étoile).
void astroide(float x, float y, float t){
float t2 = t/2;float tt=t2/2;
float[] p1 = {x,y-t2};float[] p2 = {x+t2,y};float[] p3 = {x,y+t2};float[] p4 = {x-t2,y};
beginShape();
vertex(p1[0],p1[1]);
bezierVertex(p1[0],p1[1]+tt,p2[0]-tt,p2[1],p2[0],p2[1]);
bezierVertex(p2[0]-tt,p2[1], p3[0],p3[1]-tt, p3[0],p3[1]);
bezierVertex(p3[0],p3[1]-tt, p4[0]+tt,p4[1], p4[0],p4[1]);
bezierVertex(p4[0]+tt,p4[1], p1[0],p1[1]+tt,p1[0],p1[1]);
endShape();
}
La fonction doit être placée dans le code d’un programme.
Elle s’invoque comme ceci :
astroide(x, y, taille);
où x et y sont les coordonnées horizontales et verticales du centre de l’astroïde et où taille définit le diamètre du cercle dans lequel s’inscrit la forme géométrique.
No comments
Comments feed for this article
Trackback link: https://hyperbate.fr/whatever/2010/01/23/astroide/trackback/