ArrayList Shapes = new ArrayList(); Background bg; final int CIRCLE = 0; final int RECTANGLE = 1; final int TRIANGLE = 2; class Shape{ float x, y, w, h, i, o; float r, g, b, a; int s; float life, birth; float weight; float step; int highlight = 0; int threshold; Shape() { s = (int)random(0, 2); r = random(0,255); g = random(0,255); b = random(0,255); a = random(0,2); birth = life = random(10000, 50000); step = random(1, 10); threshold = 120; x = random(0, width); y = random(0, height); switch (s) { case CIRCLE: w = random(1,width/4); break; // case TRIANGLE: /* float er = random(1, width); w = x - (er/2);//random(0, x); h = y + er;//random(y, height); i = x + (er/2);//random(x, width); o = y + er;//random(y, height); a = 150; break;*/ case RECTANGLE: default: w = random(1,width/4); h = random(1,height/4); break; } } void update() { switch (s) { case CIRCLE: if( (mouseX - x) * (mouseX - x) + (mouseY - y) * (mouseY - y) <= (w/2*w/2))//(w/1.5)*(w/1.5)) { a += random(0, step); life = birth; } break; /* case TRIANGLE: if( (mouseX > x) && (mouseX < x+w) && (mouseY > y) && (mouseY < y+h)) { a += random(0, step); life = birth; } break;*/ case RECTANGLE: default: if( (mouseX >= x) && (mouseX <= x+w) && (mouseY >= y) && (mouseY <= y+h)) { a += random(0, step); life = birth; } break; } if( a > threshold ) a = threshold; --life; } void render() { a = (life/birth) * (a); strokeWeight(1); stroke(r,g,b, a+20); fill(r,g,b, a); switch(s) { case CIRCLE: ellipseMode(CENTER); ellipse(x, y, w, w); break; /* case TRIANGLE: // rectMode(CORNERS); triangle(x, y, w, h, i, o); break; */ default: case RECTANGLE: // rectMode(CORNERS); rect(x, y, w, h); break; } } boolean isDead() { if( life <= 0 ) { a = random(0,5); life = birth = random(100, 500); return true; } return false; } } class Background { float r, g, b; float step; Background() { r = 255;//random(200, 255); g = 255;//random(200, 255); b = 255;//random(200, 255); step = 2; } void update() { r += random(-step, step); g += random(-step, step); b += random(-step, step); } void render() { background(r, g, b); } } void setup() { size(400, 400); frameRate(30); int shapesize = (int)random(100,500); for(int i = 0; i 0 ) Shapes.remove(0); int shapesize = (int)random(100,500); while( Shapes.size() < shapesize ) Shapes.add(new Shape()); }