<canvas width="600" height="400"></canvas>
<script>
var tela = document.querySelector('canvas');
var pincel = tela.getContext('2d');
pincel.fillStyle = 'lightgray';
pincel.fillRect(0, 0, 600, 400);
function desenhaQuadrado(x, y, cor) {
pincel.fillStyle = cor;
pincel.fillRect(x, y, 50, 50);
pincel.strokeStyle = 'black';
pincel.strokeRect(x, y, 50, 50);
}
var i = 0;
while( i < 150) {
desenhaQuadrado(i, 0, 'green');
i++
}
desenhaQuadrado(150, 0, 'white');
</script>