Skip to content

Instantly share code, notes, and snippets.

@shiffman
Created September 26, 2014 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shiffman/9ce6d44487542442589a to your computer and use it in GitHub Desktop.
Save shiffman/9ce6d44487542442589a to your computer and use it in GitHub Desktop.
Checkerboard Pattern
void setup () {
size (400, 400);
}
void draw () {
background (0);
int spacing = 10;
noStroke();
int cols = width / spacing;
int rows = height / spacing;
for (int x = 0; x < cols; x = x + 1) {
for (int y = 0; y < rows; y = y + 1) {
if ((x % 2 == 0 && y % 2 == 1) || (x % 2 == 1 && y %2 == 0)) {
fill(255);
} else {
fill(0);
}
rect (x*spacing, y*spacing, spacing, spacing);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment