Grid with random colors

Hi there,

I am trying to make a grid with random colors on every cell, but I only can change the color of every column and I don’t know why. Could you please help me?

size(1000,1000);
  stroke(1);
     
  for(int x=0; x<1000; x=x+100) {
    for(int y=0; y<1000; y=y+100)
    rect(x,y,100,100);
    fill(random(256),random(256),random(256)); 

  }

There are no curly braces after the second if condition check, therefore there is only action on the x.

2 Likes

Hello,

Nested loops:

https://processing.org/reference/for.html < See last example

:)

1 Like