class Blob { Color blobColor; float posx, posy, d; float v; float weight = 6.0; float flicked = 0; float origd; float bob, rad, speed; int animation; Blob(int maxX, int maxY) { posx = random(0, maxX); posy = random(0, maxY); origd = random(25, 150); d = 0; bob = 0; blobColor = new Color(); rad = random(5, 20); speed = random(0.1,0.5); } void update() { switch(animation) { case 1: bob += 1; if(bob >=360 ) bob = 0; d = d + rad * sin(bob*(speed)); break; case 2: blobColor.a -= speed * random(2, 10); break; default: if(d < origd) { d += random(0.1, 0.5); } break; } } void render() { strokeWeight(5 * (blobColor.a / 255)); stroke(0, blobColor.a); fill(blobColor.r, blobColor.g, blobColor.b, blobColor.a);//, (life/birth)*a); ellipse(posx, posy, d, d); } boolean isDead() { return (blobColor.a <=0 ); } boolean inside(int x, int y) { if( (posx - x) * (posx - x) + (posy - y) * (posy - y) <= (d/2) * (d/2) && animation != 2) return true; return false; } Color getColor() { return blobColor; } void animate(int mode) { if(animation == 2 ) return; animation = 0; if(mode > 0) animation = mode; } } class Background { float r, g, b; Color bgColor; Color toColor = new Color(); Color stepColor = new Color(); int steps, stepsize; boolean inProcess; Background() { bgColor = toColor = new Color(255, 255, 255, 255); } void update() { if(!toColor.equals(bgColor)) { transitionTo( toColor ); } } void render() { background(bgColor.r, bgColor.g, bgColor.b); } void changeBG( Color newColor ) { steps = (int)random(5, 250); toColor = newColor; stepColor.r = ((bgColor.r - newColor.r)/steps); stepColor.g = ((bgColor.g - newColor.g)/steps); stepColor.b = ((bgColor.b - newColor.b)/steps); } void transitionTo( Color newColor ) { bgColor.r -= stepColor.r; bgColor.g -= stepColor.g; bgColor.b -= stepColor.b; } }