// Viral Expansion 3 // by John Clavin float R1, G1, B1; float R2, G2, B2; color levelColor1; color levelColor2; int radius = 10; float angle1; float angle2; float angle180 = PI; float angle90 = TWO_PI/4; float angle45 = TWO_PI/8; float angle30 = TWO_PI/12; float angle15 = TWO_PI/24; int newX1, newY1, newX2, newY2; void setup() { size(700, 500); background(220); stroke(0); fill(60); smooth(); frameRate(.25); } void draw() { setColor(); background(220); explode(width/2, height/2, 15, PI/2); } void explode(int x, int y, int level, float angle) { angle1 = angle + angle90 + angle45 + random(-.5, .5); angle2 = angle - (angle90 + angle45) + random(-.5, .5); R1 += .0075; G1 -= .0075; levelColor1 = color(R1, G1, B1); R2 += .0075; G2 += .0065; B2 -= .0075; levelColor2 = color(R2, G2, B2); ellipse(x, y, 8, 8); newX1 = int(radius*cos(angle1))+x; newY1 = int(radius*sin(angle1))+y; newX2 = int(radius*cos(angle2))+x; newY2 = int(radius*sin(angle2))+y; if(level > 1) { level--; fill(levelColor1); explode(newX1, newY1, level, angle1); fill(levelColor2); explode(newX2, newY2, level, angle2); } } void setColor() { fill(60); R1 = 0; G1 = 255; B1 = 0; R2 = 0; G2 = 0; B2 = 240; }