El·lipses boges

 

Programador:

Maria Basco

Instruccions:

Mou el ratolí per sobre la finestra de l’sketch i veuràs com canvienles el·lipses boges.

 


Codi:

Cercles c;

// Si tiras el ratolí amunt a la dreta el dibuix creix
void setup() {
size(800, 600);
c=new Cercles();
frameRate(30.0);
}

void draw() {
background(255);
translate(300, 300);
smooth();
c.display();
}
ArrayList <PVector> cercle;
ArrayList <PVector> b;

class Cercles {
Cercles() {
cercle = new ArrayList <PVector>();
b = new ArrayList <PVector>();

for (int i=0; i<150; i++) {

cercle.add(new PVector(random(-20, 30), random(-20, 30)));
b.add(new PVector(random(10, 20), 10));
}
}

void display() {
for (int i=1; i<50; i++) {
PVector a= cercle.get(i-1);
PVector c= b.get(i);
fill(255);
stroke(0);
strokeWeight(i/5);
rotate(frameCount/(10*i*i*1.0));
ellipse(0, 0, 5+frameCount*map(mouseX, 0, 600, 0, 10)/i, 5+frameCount*map(mouseY, 0, 600, 0, 10)/i);
//controla el moviment de l’elipse

fill(0);
}
}
}

Deja un comentario