let c=[];
function setup(){
createCanvas(480,480);
background(220);
for(let i=0;i<1728;i++){
c[i]=random(255);
}
}
function draw(){
let cIndex=0;
for(let x=0;x<480;x+=20){
for(let y=0;y<480;y+=20){
fill(c[cIndex]);
rect(x,y,20,20);
cIndex++;
}
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.min.js"></script>