html5畫簡(jiǎn)單的圓形代碼分享,大家參考使用吧
代碼如下:
<!DOCTYPE html><head>
<meta charset=utf-8>
<title>HTML5畫圓形</title>
<script src="<a ></script</a>>
</head>
<script>
$(document).ready(function(){
var c=document.getElementById("drawbox");
var draw=c.getContext("2d"); //獲取2d內(nèi)容的引用,調(diào)用繪圖API</p> <p>draw.fillStyle="red"; //顏色
draw.beginPath(); //從新畫
draw.arc(50,50,50,0,Math.PI*2,true); //圓心x坐標(biāo)|圓心y坐標(biāo)|直徑|始|PI為圓周率,Math.PI*2為畫圓|true為時(shí)針方向:逆時(shí)針,0為順時(shí)針,
draw.closePath(); //結(jié)束
draw.fill();
})
</script>
</body>
<canvas id="drawbox" width="500" height="500"></canvas>
</body>
</html>