<meta charset="UTF-8">
<!-- esquadro.html -->
<canvas width="600" height="400"></canvas>
<script>
var tela = document.querySelector('canvas');
var pincel = tela.getContext('2d');
function desenhaEsquadro(xa, ya, xc, yc, cor) {
pincel.fillStyle=cor;
pincel.beginPath();
pincel.moveTo(xa, ya);
pincel.lineTo(xa, yc);
pincel.lineTo(xc, yc);
pincel.fill();
}
var xa = 50;
var ya = 50;
var xc = 400;
var yc = 400;
cor = 'black';
desenhaEsquadro(xa, ya, xc, yc, cor);
var xa = 100;
var ya = 175;
var xc = 275;
var yc = 350;
cor = 'white';
desenhaEsquadro(xa, ya, xc, yc, cor);
</script>