復制代碼代碼如下:
<!DOCTYPE Html><head>
<meta charset=utf-8>
<title>Html5畫圓形</title>
<script src="<a href="http://AJax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.JS"></script">http://ajax.googleapis.com/AJax/libs/jquery/1.7.1/jquery.min.JS"></script</a>>
</head>
<script>
$(document).ready(function(){
var c=document.getElementById("drawbox");
var draw=c.getContext("2d"); //獲取2d內容的引用,調用繪圖API</p><p>draw.fillStyle="red"; //顏色
draw.beginPath(); //從新畫
draw.arc(50,50,50,0,Math.PI*2,true); //圓心x坐標|圓心y坐標|直徑|始|PI為圓周率,Math.PI*2為畫圓|true為時針方向:逆時針,0為順時針,
draw.closePath(); //結束
draw.fill();
})
</script>
</body>
<canvas id="drawbox" width="500" height="500"></canvas>
</body>
</Html>