<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<script type="application/javascript">
function draw() {
var canvas = document.getElementById('canvas');
if (canvas.getContext) {
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'rgb(200, 0, 0)';
ctx.fillRect(70, 70, 50, 50);
/*ctx.fillStyle = 'rgba(0, 0, 200, 0.5)';
ctx.fillRect(90, 90, 50, 50);*/
ctx.beginPath();
ctx.moveTo(100, 40);
ctx.lineTo(70, 70);
ctx.lineTo(120, 70);
ctx.fill();
}
}
/* function draw() {
var canvas = document.getElementById('canvas');
if (canvas.getContext) {
var ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.moveTo(75, 50);
ctx.lineTo(100, 75);
ctx.lineTo(100, 25);
ctx.fill();
}
}*/
</script>
</head>
<body onload="draw();">
<canvas id="canvas" width="150" height="150"></canvas>
</body>
</html>