Skip to content

Instantly share code, notes, and snippets.

@duskvirkus
Created November 20, 2019 02:52
Show Gist options
  • Save duskvirkus/cd70df68b369e701236809730523364f to your computer and use it in GitHub Desktop.
Save duskvirkus/cd70df68b369e701236809730523364f to your computer and use it in GitHub Desktop.
Simple processing program to generate checker patterns.
int SIZE = 64;
int scale = 2;
void settings() {
size(SIZE, SIZE);
}
void setup() {
color c1 = color(255);
color c2 = color(0);
loadPixels();
for (int i = 0; i < width; i++) {
for (int j = 0; j < height / scale; j++) {
for (int k = 0; k < scale; k++) {
int y = j * scale + k;
int index = i + y * width;
if (j % 2 == 0) {
pixels[index] = i % (scale * 2) < scale ? c1 : c2;
} else {
pixels[index] = i % (scale * 2) < scale ? c2 : c1;
}
}
}
}
updatePixels();
save("checkers-" + SIZE + "-" + scale + ".png");
exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment