int numCircles = 30;
ArrayList<Circle> circles;
void setup(){
size(500, 500);
noStroke();
smooth();
background(255);
frameRate(30);
circles = new ArrayList<Circle>();
for(int i = 0; i < numCircles; i++){
circles.add(new Circle());
}
}
void draw(){
background(255);
for(int i = 0; i < numCircles; i++){
circles.get(i).updateAngle();
circles.get(i).draw();
}
}
class Circle{
float revolutionRadious;
float angle;
float angularVelocity;
float cirlceRadious = 30;
float colorR;
float colorG;
float colorB;
Circle(){
this.revolutionRadious = random(1) * 200 + 50;
this.angle = 0.0;
this.angularVelocity = (PI / 24.0) * (2.0 * random(1) - 1.0);
this.colorR = (int)random(256);
this.colorG = (int)random(256);
this.colorB = (int)random(256);
}
void updateAngle(){
this.angle += this.angularVelocity;
if(this.angle < 0){
this.angle = 2.0 * PI + this.angle;
} else if(2.0 * PI < this.angle){
this.angle = this.angle - 2.0 * PI;
}
}
void draw(){
fill(this.colorR, this.colorG, this.colorB);
float x = this.revolutionRadious * cos(this.angle);
float y = this.revolutionRadious * sin(this.angle);
arc(x + width / 2, y + height / 2.0, cirlceRadious, cirlceRadious, 0, 2*PI);
}
}