<canvas width= "600" height= "400"></canvas>
<script>
function desenhaTriangulo(xa, ya, xc, yc, cor) {
var tela= document.querySelector("canvas");
var pincel= tela.getContext("2d");
pincel.fillStyle= cor;
pincel.beginPath();
pincel.moveTo(xa, ya);
pincel.lineTo(xa, xc);
pincel.lineTo(xc, yc);
pincel.fill();
}
function desenhaTrianguloMenor(xa, ya, xc, yc, cor) {
var tela= document.querySelector("canvas");
var pincel= tela.getContext("2d");
pincel.fillStyle= cor;
pincel.beginPath();
pincel.moveTo(xa, ya);
pincel.lineTo(xa, xc);
pincel.lineTo(xa + ya, yc);
pincel.fill();
}
desenhaTriangulo(50, 50, 400, 400, "black");
desenhaTrianguloMenor(100, 175, 350, 350, "white");
</script>