canvas 绘制圆形
绘制半圆:
<head> <meta charset="utf-8"> <title>无标题文档</title> <script type="text/ecmascript"> function draw(){ var canvas=document.getElementById("test"); if(canvas.getContext){ var ctx=canvas.getContext("2d"); ctx.arc(75,75,50,-Math.PI/2,Math.PI/2,false); //圆心起始坐标,圆的半径,圆弧相对x轴的起始、结束位置,false为顺时针(true逆时针) ctx.stroke(); }; }; </script> </head> <body onLoad="draw();"> <canvas id="test" width="150" height="150"></canvas> </body>