var bg = document.getElementById('canvas1');
var ctx = bg.getContext('2d');
ctx.beginPath();
var height = 200*Math.sin(Math.PI/3);
ctx.moveTo(100,0);
ctx.lineTo(0,height);
ctx.lineTo(200,height);
var grd = ctx.createLinearGradient(0,0,200,0);
grd.addColorStop(0,"#4CE8B2");
grd.addColorStop(1,"#EFD458");
ctx.fillStyle=grd;
ctx.fill();
<canvas id="canvas1"></canvas>
<script type="text/javascript">
function hT(id,x1, y1, x2, y2, x3, y3, color, type){
var canvas = document.getElementById(id);
var ctx = canvas.getContext("2d");
ctx.beginPath();
ctx.moveTo(x1, y1);
ctx.lineTo(x2, y2);
ctx.lineTo(x3, y3);
ctx[type + 'Style'] = color;
ctx.closePath();
ctx[type]();
}
hT("canvas1",77,3,4,132,151,133, "red", "fill")
</script>