/* Based on older computer games/graphics that could not compute high resolution texture.
Based on the times when grass was nothing more than brown and green pixels times 16 */
//initial color values;
int hmax = 97; //Highest green hue (also the starting green hue);
int h = hmax;
int hmin = 68;
int s1=67;
int s2=110;
int b1=70;
int b2=150;
int gdwn = 1; //indicator if the colors are moving down in hue
int lim = 16; //size of a square
void setup() {
size(400,400);
colorMode(HSB);
noStroke();
frameRate(2);
}
void draw(){
for(int i=0; i<=(height-lim); i+=lim) {
for(int j=0; j<=(width-lim); j+=lim) {
colour_block(s1,s2,b1,b2,j,i);
}
}
if (h>=hmin && gdwn == 1) {
h -= 2;
b1 += 2;
b2 += 3;
s1 += 1;
s2 += 1;
}
else if (h<=hmax && gdwn == 0) {
h += 2;
b1 -= 2;
b2 -= 3;
s1 -= 1;
s2 -= 1;
}
else if (h<hmin && gdwn == 1) {
gdwn = 0;
h+=2;
}
else {
gdwn = 1;
h-=2;
}
}
void colour_block(int sl, int su, int bl, int bu, int x, int y) { //saturation lower and upper boundaries, bright lower and upper boundaries, x and y coordinates
int hues = int(random(h-25,h));
int sat = int(random(sl,su));
int bright = int(random(bl,bu));
fill(hues,sat,bright);
rect(x,y,16,16);
}