<meta charset="UTF-8">
<canvas width= "600" height="400"></canvas>
<script>
var tela = document.querySelector('canvas');
var pincel = tela.getContext('2d');
function trabalho (color,x,y,a,b) {
pincel.fillStyle = color;
pincel.beginPath();
pincel.moveTo(x,a);
pincel.lineTo(x,y);
pincel.lineTo(b,y);
pincel.fill();
}
trabalho('black',50,400,50,400);
trabalho("white",100,350,175,275);
</script>