Olivier — 2014-11-22 02:06:02

Je continue sur ma lancée... :P

http://codelab.fr/up/ligne.gif

Code (P5) :

Lili[] tableau;

void setup() {

  size(400, 400);
  noStroke();

  tableau = new Lili[18];
  for (int i = 0; i < tableau.length; i++) {
    tableau[i] =  new Lili(i);
  }
}

void draw() {

  for (int i = 0; i < tableau.length; i++) tableau[i].affiche();
}

class Lili {

  float angle;
  int numero;
  float valAngle;
  float coef = 400;

  Lili (int num) {

    numero = num;
    angle = num*10;
  }

  void affiche() {

    if (numero%2 == 0) fill(0);
    else fill(255, 255, 0);

    beginShape();
    vertex(0, height);    
    bezierVertex(cos(radians(angle))*coef, 
                 cos(radians(angle))*coef, 
                 width-cos(radians(angle))*coef, 
                 cos(radians(angle))*coef, 
                 width, 
                 height);
                 
    bezierVertex(width-cos(radians(angle+10))*coef, 
                 cos(radians(angle+10))*coef, 
                 cos(radians(angle+10))*coef, 
                 cos(radians(angle+10))*coef, 
                 0, 
                 height);
    endShape();   

    if (angle < 179) angle += 0.5;
    else angle = 0;
  }
}