<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
<canvas id="myCanvas" width="400" height="300" style="border:1px solid red" >对不起,您的浏览器不支持画布</canvas>
<script>
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.beginPath();
ctx.moveTo(10,10);
ctx.lineTo(390,10);
ctx.lineTo(390,290);
ctx.closePath();
ctx.stroke();
ctx.beginPath();
ctx.moveTo(10,10);
ctx.lineTo(10,290);
ctx.lineTo(390,290);
ctx.closePath();
ctx.fillStyle="pink";
ctx.fill();
ctx.beginPath();
ctx.arc(200,150,100,0,Math.PI*2,true);
ctx.fillStyle="yellow";
ctx.stroke();
ctx.fill();
ctx.beginPath();
ctx.arc(150,120,20,0,Math.PI*2,true);
ctx.arc(250,120,20,0,Math.PI,true);
ctx.fillStyle="black";
ctx.fill();
ctx.beginPath();
ctx.arc(200,170,50,0,Math.PI,false);
ctx.fillStyle="red";
ctx.fill();
ctx.stroke();
ctx.beginPath();
ctx.clearRect(150,110,10,10);
</script>
</body>
</html>