<meta charset="utf-8">
<canvas width="600" height="400" ></canvas>
<script>
var tela = document.querySelector("canvas");
var pincel = tela.getContext("2d");
function triangulo(xa, ya, xc, yc, color){
pincel.fillStyle = (color);
pincel.beginPath();
pincel.moveTo(xa, ya);
pincel.lineTo(xa, yc);
pincel.lineTo(xc, yc);
pincel.fill();
}
triangulo(50, 50, 400, 50, "black");
</script>