import java.util.*; ArrayList occs; final static float PHASE = (float)(PI*Math.E); final static int MAX_RADIUS = 250; final static int AMP = 5; final static int TYPE = 0; //color constants final static int RED_BASE = 20; final static int RED_VARI = 30; final static int BLUE_BASE = 156; final static int BLUE_VARI = 100; final static int GREEN_BASE = 50; final static int GREEN_VARI = 50; void setup(){ size(500, 500); background(55); smooth(); ellipseMode(CENTER); fill(0,0,0,0); stroke(0); strokeWeight(2); frameRate(15); occs = new ArrayList(); if(TYPE == 0){ for(float t = 0; t < 100; t+=.25){ float x = (float)(AMP*t*Math.cos(PHASE*t)); float y = (float)(AMP*t*Math.sin(PHASE*t)); x+=width/2; y+=height/2; int radius = MAX_RADIUS - (int)sqrt(sq(x - width/2) + sq(y - height/2)); if(radius > 1){ occs.add( new occ( x, y, radius/3) ); } } }else{ int curx = 0; int cury = 0; int multx = 20; int multy = 20; for(int i = 0; i < 1000; i++){ curx += (multx * i); multx *= -1; for(int j = 0; j < 1000; j++){ cury += (multy * j); multy *= -1; int posx = width/2 + curx; int posy = height/2 + cury; int radius = 450 - (int)sqrt(sq(posx - width/2f) + sq(posy - height/2f)); if(radius > 0){ occs.add( new occ( posx, posy, radius/2) ); } } cury = 0; } } } void draw(){ background(255); for(int i = 0; i < occs.size(); i++){ occ o = (occ)occs.get(i); o.tick(); o.render(); } } //void mousePressed(){ // saveFrame(); //} public class occ{ private float x; private float y; private int maxRadius; private int curRadius; private int step; private color col; private int alph; public occ(float x, float y, int maxRadius){ this(x,y,maxRadius,0); } public occ(float x, float y, int maxRadius, int initialRadius){ this.x = x; this.y = y; this.curRadius = initialRadius; this.maxRadius = maxRadius; this.alph = 100; this.step = 1; this.col = color( random(RED_VARI) + RED_BASE, random(BLUE_VARI)+BLUE_BASE ,random(GREEN_VARI)+GREEN_BASE); } public void tick(){ this.curRadius += this.step; if(this.curRadius >= this.maxRadius || this.curRadius <= 0){ this.step = -1 * this.step; } } public void render(){ this.alph += random(5) - 2; fill(red(this.col), blue(this.col), green(this.col), this.alph); ellipse(this.x, this.y, this.curRadius, this.curRadius); } }