Created
September 26, 2014 16:46
-
-
Save shiffman/9ce6d44487542442589a to your computer and use it in GitHub Desktop.
Checkerboard Pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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