Burbuja burbujas2 = new Burbuja(int(random(300)), int(random(400)), int(random(255)));
Burbuja burbujas3 = new Burbuja(int(random(300)), int(random(400)), int(random(255)));
Burbuja burbujas4 = new Burbuja(int(random(300)), int(random(400)), int(random(255)));
Burbuja burbujas5 = new Burbuja(int(random(300)), int(random(400)), int(random(255)));
Burbuja burbujas6 = new Burbuja(int(random(300)), int(random(400)), int(random(255)));
Burbuja burbujas7 = new Burbuja(int(random(300)), int(random(400)), int(random(255)));
Burbuja burbujas8 = new Burbuja(int(random(300)), int(random(400)), int(random(255)));
void setup() {
size(300, 400);
}
void draw(){
background (255, 204, 0);
burbujas1.mostrar();
burbujas2.mostrar();
burbujas3.mostrar();
burbujas4.mostrar();
burbujas5.mostrar();
burbujas6.mostrar();
burbujas7.mostrar();
burbujas8.mostrar();
}
class Burbuja {
float x;
float y;
color c;
int n = 2;
float tam = 10;
Burbuja(float burbuja_x, float burbuja_y, color burbuja_c) {
x = burbuja_x;
y = burbuja_y;
c = burbuja_c;
}
void mostrar(){
fill(c);
stroke(0, 0, 0);
tam = (tam *1.008);
y = y-n;
if (y < 0) {
y = height+n;
tam = 10;
}
ellipse(x, y, int(tam), int(tam));
}
}
(C) Fernando Morán
IES Antonio Machado
Alcalá de Henares
Marzo 2016