Last active
August 29, 2015 14:02
-
-
Save flightcrank/7387beda0e8a644e5351 to your computer and use it in GitHub Desktop.
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
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