int X = 40, Y = 40; float DX, DY, R1, R2; void setup() { size(600, 600); frameRate(20); smooth(); noStroke(); rectMode(CENTER); DX = width / X; DY = height / Y; colorMode(HSB, 255); mousePressed(); } void mousePressed() { R1 = random(-5, 5); R2 = random(-5, 5); } void draw() { float xc = DX / 2; background(0, 64, 64); beginShape(QUADS); for (int x = 0; x < X; x++, xc += DX) { float yc = DY / 2; for (int y = 0; y < Y; y++, yc += DY) { float s1 = 128 + 128 * sin(radians(xc) * sin( radians(frameCount * R1)) ); float s2 = 128 + 128 * sin(radians(yc) * sin( radians(frameCount * R2)) ); float s3 = 128 + 128 * sin(radians((xc + yc + frameCount * 10) / 2)); float s = (s1 + s2 + s3) / 3; fill(s, 255 - s / 2.0, 255); vertex(xc - DX / 2, yc - DY / 2); fill(s, 255 - s / 4.0, 255); vertex(xc + DX / 2, yc - DY / 2); fill(s, 255 - s / 6.0, 255); vertex(xc + DX / 2, yc + DY / 2); fill(s, 255 - s / 8.0, 255); vertex(xc - DX / 2, yc + DY / 2); } } endShape(); }