Skip to content

Instantly share code, notes, and snippets.

@flightcrank flightcrank/texture.pde
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.