xxxxxxxxxx
int counter;
int nbPts;
float deltaH, deltaS, f;
PVector[] pts;
void setup(){
size(480, 700, P2D);
colorMode(HSB, 2);
strokeWeight(2);
noFill();
initialize();
}
void draw(){
f = float(frameCount);
stroke(1+cos(deltaH-f/280), 1+sin(deltaS+f/220), 2, .15);
for(int i = 0; i < nbPts; i ++){
pts[i].x += random(-1.5, 3);
pts[i].y += random(-3, 3);
}
beginShape();
vertex(pts[0].x, 0);
for(int i = 0; i < nbPts; i ++){
curveVertex(pts[i].x, pts[i].y);
}
vertex(pts[nbPts-1].x, height);
endShape(CLOSE);
beginShape();
vertex(width-pts[0].x, 0);
for(int i = 0; i < nbPts; i ++){
curveVertex(width-pts[i].x, pts[i].y);
}
vertex(width-pts[nbPts-1].x, height);
endShape(CLOSE);
}
void initialize(){
background(.1);
deltaH = random(TWO_PI);
deltaS = random(TWO_PI);
nbPts = (int)random(6, 35);
pts = new PVector[nbPts];
for(int i = 0; i < nbPts; i ++){
pts[i] = new PVector(width/2, i*height/nbPts);
}
}
void mousePressed(){
initialize();
}