[NEWBz] Function within a conditional?

Hello!

I'm trying to make a board of squares on square grid with random colors and dimensions ranging from int 10-30. I've made this happen, but I want to try to do it with functions instead of the conditionals themselves, but I can't figure out how to do that. Also I want the row and column of the square I press to change colors randomly when I click on it. Any help is much appreciated guys!

Thanks,

Chris Bosh

Here's what I have so far:

int n = int(random(10,30));
int z = int(random(10,30));

void setup() {
  size(n*z,n*z);
  background(255);

  for(int x = 0; x < width; x = x + z) {
    for(int y = 0; y < height; y = y + z) {
       noStroke();
       fill(random(255),random(255),random(255));
       rect(x,y,z,n);
  }
}
Tagged:

Answers

Sign In or Register to comment.