<canvas width="600" height="400"></canvas>
<script>
var tela = document.querySelector('canvas');
var pincel = tela.getContext('2d');
function desenhaQuad(x, y, dx, dy, cor) {
pincel.fillStyle = cor;
pincel.fillRect(x, y, dx, dy);
pincel.strokeStyle = 'black';
pincel.strokeRect(x, y, dx, dy);
}
var x = 0
while (x<=150){
if(x<=100){
desenhaQuad(x, 0, 50, 50, 'blue');
} else{
desenhaQuad(x, 0, 50, 50, 'white');
}
x = x + 50;
}
</script>