
Another exploration we can achieve with nested loops is to generate interesting textures by using mathematical operators like the modulo, which allows us to create a smooth transition between colors. A very basic, but visually appealing example.
void setup() {
size(600, 400);
}
void draw() {
background(0);
noStroke();
int step = 40;
for (int i = step; i < width; i += step) {
for (int j = step; j < height; j += step) {
fill(i % 255, j % 255, 150);
print("R:" + str(i%255)+ "G:" + str(j%255));
ellipse(i, j, 35, 35);
}
}
}
