html5 canvas元素各種圓形繪製
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
canvas{background: #b8edc9;}
</style>
</head>
<body>
<h5>Canvas</h5>
<canvas id="mycanvas" width="1000" height="1000">
您的瀏覽器不支援html5dcanvas元素
</canvas>
<script type="text/javascript">
var canvas=document.getElementById('mycanvas');//定義變數獲取畫布dom
var c=mycanvas.getContext('2d');//設定繪圖環境2d
c.lineWidth=4;//設定線寬
c.strokeStyle="#A52A2A";//設定邊顏色
//繪製圓
c.fillStyle="gold";
c.arc(50,350,30,0,Math.PI*2)//Math.PI*2表示角度
c.stroke();
//繪製實心
c.beginPath();
c.arc(50,430,30,0,Math.PI*2)//
c.fill()
//繪製有邊的實心圓
c.beginPath();
c.lineWidth=3;
c.strokeStyle="darkblue";
c.fillStyle="gold";
// c.arc(50,260,30,0,Math.PI*2)
// c.stroke();
// c.beginPath();
// c.arc(50,260,30,0,Math.PI*2)
// c.fill()
c.beginPath();
c.arc(50,260,30,0,Math.PI*2)
c.stroke();
c.fill()