• Show Code
/** @peep sketch **/
 
int NUM_CIRCLES = 100;
float MIN_RADIUS = 25;
float MAX_RADIUS = 45;
 
Circle[] circles;
 
void setup() {
  size(300, 300);
  frameRate(10);
  smooth();
  circles = new Circle[NUM_CIRCLES];
  for (int i = 0; i < circles.length; i++) {
    circles[i] = new Circle(random(width), random(height), random(MIN_RADIUS, MAX_RADIUS));
  }
}
 
void update() {
  for (int i = 0; i < circles.length; i++) {
    circles[i].update();
  }
}
 
void draw() {
  update();
  background(255);
  for (int i = 0; i < circles.length; i++) {
    circles[i].draw();
  }
}
 
class Circle {
  float x;
  float y;
  float radius;
 
  float heading;
  float speed;
 
  Circle(float _x, float _y, float _radius) {
    x = _x;
    y = _y;
    radius = _radius;
    heading = random(TWO_PI);
    speed = 10;
  }
 
  void update() {
    x += random(-10, 10);
    y += random(-10, 10);
  }
 
  void draw() {
    pushStyle();
    noFill();
    stroke(0);
    strokeWeight(1);
    ellipseMode(RADIUS);
    pushMatrix();
    translate(x, y);
    ellipse(0, 0, radius, radius);
    popMatrix();
    popStyle();
  }
}

Comments

Nobody has said anything yet.