xxxxxxxxxx
int numOfBoxes = 30;
Box[] boxes = new Box[numOfBoxes];
float pressedX = 250;
float pressedY = 250;
float B=150;
float G=150;
void setup(){
size(500,500);
noStroke();
rectMode(CENTER);
for(int i =0; i<boxes.length;i++){
boxes[i] = new Box();
}
frameRate(10);
}
void draw(){
background(0);
float newSize = 1000;
boxes[0].col = color(random(50,200),B,G);
for(int i = boxes.length-1; i>0;i--){
boxes[i].size = newSize;
boxes[i].col = boxes[i-1].col;
newSize-=34;
boxes[i].xPos = pressedX;
boxes[i].yPos = pressedY;
}
boxes[0].size = 100;
for(int i = boxes.length-1; i>0;i--){
boxes[i].makeBox();
}
}
void mousePressed(){
pressedX = mouseX;
pressedY = mouseY;
B=random(50,200);
G=random(50,200);
}
class Box {
float xPos;
float yPos;
float size;
color col;
Box(){
xPos = width/2;
yPos = height/2;
size = width/2;
col = color(0);
}
void makeBox(){
fill(col);
rect(xPos,yPos,size,size);
}
}