float fade = 0.0; color bg = color(random(255),random(255),random(255)); int newR, newG, newB; void setup() { size( $(window).width(), $(window).height() ); background(bg); frameRate(30); } void draw() { background(bg); fade = frameCount % 240; if (fade == 0) { switchcolor(); } else { fade = map(fade, 0, 240, 0, 255); fill(newR, newG, newB, fade); rect(-10,-10,width+10,height+10); } } void switchcolor() { bg = color(newR, newG, newB); background(bg); newR = int(random(255)); newG = int(random(255)); newB = int(random(255)); }