submission by jtoy
function setup(){
  var myCanvas = createCanvas(windowWidth,windowHeight); //you must keep this line unmodified
 rects = []
  colors = [255,200,100,70 ]
  for(i=0;i<1500;i++){
    rects.push({x:random(width),y:random(height),s:random([5,5,5,5,5,5,10,10,10,10,10,20,20,30]) , spx:random(-5,5) ,spy:random(-2,2),c:random(colors)})
  }
  start= millis()
  position= 0
}
function fill_color(position,c){
  if(position == 0){
    fill(c,0,0)
  }else if (position == 1){
    fill(0,c,0)
  }else if (position == 2){
    fill(c,0,c)
  }else{
    fill(0,0,c)
  }
}

function draw() {
  //start writing your code here
  noStroke()
  background(0)
  for(i=0;i<rects.length;i++){
     r = rects[i]
     x = r.x
     y=r.y
     s=r.s
     spx = r.spx
     spy = r.spy
     c = r.c

    fill_color(position,c)
    if(start+5000 < millis()){
      start=millis()
      position= ((position+1)%4)
    }
     rect(x,y,s,s)  
     if(random(1) >0.999){
       x+= random(-2,2)
       y+= random(-2,2)
     }
      x+= spx
      y+= spy
     if(x> width*1.5 && spx>0){
       x=-r.s
     }
     if(x< 0 && spx<0){
       x=width+r.s
     }
     if(y< 0 && spy<0){
       y=height+r.s
     }

    rects[i] = {x:x,y:y,s:s,spx:spx,spy:spy,c:c}
   }

}