<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="300" height="200" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.
</canvas>
<script>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.fillRect(50,50,200,100);
ctx.fillStyle="red"
ctx.fillRect(50,50,30,10);
ctx.fillStyle="green"
ctx.fillRect(10,10,30,10);
ctx.strokeStyle="red";
ctx.moveTo(1,1)
ctx.lineTo(60,70)
ctx.stroke()
ctx.fillStyle="white"
ctx.font = '30px 微软雅黑'
ctx.textAlign="center"
ctx.fillText("测试一下",150,80);
ctx.rect(40, 40, 120, 100)
ctx.strokeStyle="blue";
ctx.stroke();
ctx.font="20px Georgia";
ctx.textAlign="start"
ctx.strokeText('空心的字体', 40,30);
ctx.clearRect(10, 10, 60, 60);
</script>
</body>
</html>