colorMode (HSB, 360, 100, 100);
for (int i = 0; i < cir.length; i++)
int dir = (int) random (2);
int centerX = (int) random (width);
int centerY = (int) random (height);
int c = color (random (160), random (80, 90), random (80, 90), 255);
int d = (int) random (10, 60);
int cdir = (int) random (3);
c = color (0, 0, (cdir == 0 ? 100 : 0), (cdir == 2 ? 80 : 255));
timeSpeed = random (0.01, 0.4);
c = color (random (150, 360), random (80, 90), random (80, 90), 255);
cir [i] = new Circles ((int) random (10, 70), centerX, centerY, c, (int) (2.0*dist (centerX < width/2 ? 0 : width, centerY < height/2 ? 0 : height, centerX, centerY)), d, dir, timeSpeed);
if (mode != 0) background (0, 0, 100);
for (int i = 0; i < cir.length; i++)
if (mode == 0) cir[i].moveCenter();
private float [] angle, dia, ellD, weighting;
private int n, posX, posY, c, d, startD, noiseSeedNum, ellipseD, dir, centerDirX, centerDirY;
private float time = 0, speed, centerSpeed, timeSpeed;
Circles (int n, int posX, int posY, int c, int d, int ellipseD, int dir, float timeSpeed)
this.timeSpeed = timeSpeed;
this.centerDirX = this.centerDirY = 1;
this.centerDirX = this.centerDirY= -1;
this.ellipseD = ellipseD;
noiseSeedNum = (int) random (1000);
startD = (int) random (10, d/3);
centerSpeed = random (.75, 2);
weighting = new float [n];
float steps = 360.0 / (float) n;
float diaSteps = ((float) d/2 - (float) startD) / (float) n;
float startAngle = random ( 360);
float dSteps = ((float) ellipseD - 1.0) / n;
for (int i = 0; i < n; i++) {
angle [i] = startAngle + steps * dir * random (i-0.5, i+0.5);
dia [i] = (float) i * diaSteps;
ellD [i] = dSteps * (float) i * random (0.5, 1.5);
public void moveCenter ()
noiseSeed (noiseSeedNum);
posX += noise (time/2.0)*centerSpeed*centerDirX;
posY += noise (time/2.0)*centerSpeed*centerDirY;
d = (int) (2.0*dist (posX < width/2 ? 0 : width, posY < height/2 ? 0 : height, posX, posY));
float diaSteps = ((float) d/2 - (float) startD) / (float) n;
for (int i = 0; i < n; i++) dia [i] = (float) i * diaSteps;
noiseSeed (noiseSeedNum);
float speed_ = noise (time) * speed;
for (int i = 0; i < n; i++) angle [i] += speed_*dir;
for (int i = 0; i <n; i++)
x = posX + cos (radians (angle [i])) * (dia[i] + startD);
y = posY + sin (radians (angle [i])) * (dia[i] + startD);
ellipse (x, y, ellD [i] + 1, ellD [i] + 1);