html5中canvas繪製圓形
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>canvas繪製圓形</title>
</head>
<body>
<canvas id="myCanvas" width="500" height="500"></canvas>
<!--
圓弧:context.arc(x,y,radius,starAngle,endAngle,anticlockwise)
x:圓心的x座標
y:圓心的y座標
straAngle:開始角度(整個圓周為2PI,右邊正東方為0PI,然後順時針旋轉)
endAngle:結束角度(參考網址:http://www.108js.com/article/article7/70206.html?id=1036)
anticlockwise:是否逆時針(true)為逆時針,(false)為順時針
-->
<script type="text/javascript">
var canvas=document.getElementById("myCanvas");
var context=canvas.getContext("2d");
context.beginPath();
context.arc(200,150,100,0,Math.PI*3/2,true);
context.closePath();
context.fillStyle="rgba(0,255,0,0.25)";
context.fill();
//左側1/4圓弧
context.beginPath();
context.arc(100,150,50,Math.PI/2,Math.PI,false);
context.fillStyle='rgba(255,0,0,0.25)';
context.fill();
context.strokeStyle='rgba(255,0,0,0.25)';
context.closePath();
context.stroke();
</script>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>canvas繪製圓形</title>
</head>
<body>
<canvas id="myCanvas" width="500" height="500"></canvas>
<!--
圓弧:context.arc(x,y,radius,starAngle,endAngle,anticlockwise)
x:圓心的x座標
y:圓心的y座標
straAngle:開始角度(整個圓周為2PI,右邊正東方為0PI,然後順時針旋轉)
endAngle:結束角度(參考網址:http://www.108js.com/article/article7/70206.html?id=1036)
anticlockwise:是否逆時針(true)為逆時針,(false)為順時針
-->
<script type="text/javascript">
var canvas=document.getElementById("myCanvas");
var context=canvas.getContext("2d");
context.beginPath();
context.arc(200,150,100,0,Math.PI*3/2,true);
context.closePath();
context.fillStyle="rgba(0,255,0,0.25)";
context.fill();
//左側1/4圓弧
context.beginPath();
context.arc(100,150,50,Math.PI/2,Math.PI,false);
context.fillStyle='rgba(255,0,0,0.25)';
context.fill();
context.strokeStyle='rgba(255,0,0,0.25)';
context.closePath();
context.stroke();
</script>
</body>
</html>
相關文章
- canvas 繪製圓形Canvas
- HTML5 Canvas使用路徑——繪製圓形HTMLCanvas
- html5中的canvas繪製橢圓的方法HTMLCanvas
- 使用canvas繪製圓形進度條Canvas
- HTML5使用canvas繪製圖形HTMLCanvas
- canvas繪製圓形框效果不填充內部Canvas
- canvas繪製圓形鐘錶程式碼例項Canvas
- canvas繪製實心圓形程式碼例項Canvas
- html5中canvas繪製矩形HTMLCanvas
- Vue canvas繪製圓形進度條動畫載入VueCanvas動畫
- canvas 繪製圓角矩形Canvas
- html5中canvas繪製線段HTMLCanvas
- 【Web前端基礎知識】如何使用Canvas繪製圓形Web前端Canvas
- SVG <circle> 繪製圓形SVG
- 使用canvas繪製圓弧動畫Canvas動畫
- canvas繪製不重合的圓Canvas
- html5中canvas線段繪製太陽花HTMLCanvas
- canvas繪製圓形圖案程式碼示例簡單介紹Canvas
- canvas繪製多個圓圈效果Canvas
- html5中canvas繪製貝塞爾曲線HTMLCanvas
- Canvas 繪製 3d 圓柱體Canvas3D
- html5中canvas貝塞爾曲線繪製菊花HTMLCanvas
- html5 canvas學習--繪製文字HTMLCanvas
- BitmapShader繪製圓形圖片
- css繪製圓形程式碼例項CSS
- 微信小程式 canvas圓角矩形的繪製微信小程式Canvas
- canvas繪製圓盤走動鐘錶效果Canvas
- canvas繪製圓角矩形程式碼例項Canvas
- canvas繪製橢圓效果程式碼例項Canvas
- canvas核心技術-如何繪製圖形Canvas
- canvas繪製三角形Canvas
- Python 在PDF中繪製線條、矩形、橢圓形Python
- html5利用canvas圓形和多邊形程式碼例項HTMLCanvas
- 使用 HTML5 Canvas 繪製的水滴效果HTMLCanvas
- canvas繪製網狀圓圈程式碼例項Canvas
- WPF基礎:在Canvas上繪製圖形Canvas
- HTML5 Canvas ( 矩形的繪製 ) rect, strokeRect, fillRectHTMLCanvas
- 原來 Canvas 也能直接繪製圓角矩形了Canvas