overlayed squares
@author
ArrayList<Square> squares;
void setup(){
size(500, 500);
strokeWeight(5);
colorMode(HSB, 360, 100, 100);
mousePressed();
}
void mousePressed(){
squares = new ArrayList<Square>();
for(int i = 0; i < 20; i++){
squares.add(new Square());
}
background(0);
}
void draw(){
rectMode(CORNER);
fill(0, 100, 0, 10);
noStroke();
rect(0, 0, width, height);
translate(width / 2, height / 2);
for(Square s: squares){
s.display();
s.update();
}
}
class Square{
PVector loc;
color c;
Square(){
float locAng = random(TWO_PI);
loc = new PVector(500 * cos(locAng), 500 * sin(locAng));
c = color(random(360), 100, 100, 40);
}
void display(){
noFill();
stroke(c);
rectMode(CENTER);
rect(loc.x, loc.y, 250, 250);
}
void update(){
PVector vel = PVector.mult(loc, -1);
vel.normalize();
vel.limit(10);
loc.add(vel);
}
}