<html lang="en-US">
<canvas id=myCanvas width=500px height=500px></canvas>
<script>
var myCanvas = document.getElementById("myCanvas");
var context = myCanvas.getContext("2d");
var wise = true;
context.lineWidth = 3;
context.strokeStyle = "blue";
context.fillStyle = "red";
for(var i=1;i<5;i++)
{
for(var j=1;j<4;j++)
{
context.beginPath();
context.arc(j*100,i*100,40,0,j*2/3*Math.PI,wise);
if(1 == i||3 == i)
context.stroke();
else
context.fill();
wise = !wise;
}
}
</script>
</html>
利用arc(x,y,r,startAngle,endAngle,anticlockwise),画弧线,(x,y)表示圆心的坐标,(startAngle,endAngle)表示起末角度,anticlockwise的选择为哪个方向画圆。