Skip to content

Instantly share code, notes, and snippets.

@flightcrank
Last active August 29, 2015 14:02
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 flightcrank/7387beda0e8a644e5351 to your computer and use it in GitHub Desktop.
Save flightcrank/7387beda0e8a644e5351 to your computer and use it in GitHub Desktop.
PImage generateTex(int w, int h) {
PImage img = createImage(w, h, ARGB);
//size of each checker square
int size = 64;
color c = color(0);
//loop through each pixel in the image (img)
for(int i = 0; i < img.width; i++) {
//alternate between colours after size(in pixels) has been reached
if (i % size == 0) {
if (c == color(255)) {
c = color(0);
} else {
c = color(255);
}
}
for(int j = 0; j < img.height; j++) {
if (j % size == 0) {
if (c == color(255)) {
c = color(0);
} else {
c = color(255);
}
}
//set the pixel[x][y] co-ordinate to a colour value
img.set(i, j, c);
}//inner loop
}//outer loop
return img;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment