Tut­o­r­i­a­l 14

by Giselle Gray
  • Show Sketch
/** @peep sketchcode */
Square[] squares  ;
 
void setup() {
  size(300, 300);
  colorMode(HSB, 360, 100, 100);
  squares = new Square[100];
  for (int i = 0; i < squares.length; i++) {
    squares[i] = new Square();
    squares[i].x = random(width);
    squares[i].y = random(height);
    squares[i].objWidth = random(50);
    squares[i].colour = color(random(360), 100, 100);
  }  
}
 
void draw() {
  noStroke();
  for (int i = 0; i < squares.length; i++) {
    fill(squares[i].colour);
    rect(squares[i].x, squares[i].y, squares[i].objWidth, squares[i].objWidth);
  }
}
 
class Square {
  float x;
  float y;
  float objWidth;
  color colour;
}

Comments

Nobody has said anything yet.