function setup() { createCanvas( 780, 780); fill( 0 ); noStroke(); pg = createGraphics(780, 780); drawSquares(); } function draw() { } function drawSquares() { background(240 ); pg.background( 240 ); for( var r = 2; r < 22; r++ ) { for( var c = 0; c < 32; c++ ) { var rand = int(round(random(0,1))); pg.noStroke(); if( rand == 1 ) { pg.fill( 10 ); } else { pg.noFill(); } pg.rect( r*32, c*32, 32, 32 ); } } rotate(-0.01); translate( -8, 0, 0 ); image(pg, 0, 0); } function mousePressed() { drawSquares(); }