Bug in logic for creating checkerboard grid

Thank you for helping me out of my brain derp. Brain wanted the last two params to be ending x and y point of the rect. :pray:

The following code now works:

background(255);
int fillColor = 0;

int gridDimensions = 32;

for (int i = 0; i < gridDimensions; i++) {
  if (gridDimensions % 2 == 0)fillColor ^= 1;
  for (int j = 0; j < gridDimensions; j++) {
    fillColor ^= 1;
    fill(fillColor*255, 50);
    rect(
      i*width/gridDimensions,
      j*height/gridDimensions,
      width/gridDimensions,
      height/gridDimensions);
  }
}
1 Like