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
- 使用canvas繪製圓形進度條Canvas
- canvas繪製圓形框效果不填充內部Canvas
- canvas繪製圓形鐘錶程式碼例項Canvas
- canvas 繪製圓角矩形Canvas
- 【Web前端基礎知識】如何使用Canvas繪製圓形Web前端Canvas
- Vue canvas繪製圓形進度條動畫載入VueCanvas動畫
- canvas繪製不重合的圓Canvas
- canvas 繪製立體圓環Canvas
- SVG <circle> 繪製圓形SVG
- 使用canvas繪製圓弧動畫Canvas動畫
- canvas繪製多個圓圈效果Canvas
- Canvas 繪製 3d 圓柱體Canvas3D
- canvas核心技術-如何繪製圖形Canvas
- Python 在PDF中繪製線條、矩形、橢圓形Python
- canvas繪製圓盤走動鐘錶效果Canvas
- css繪製圓形程式碼例項CSS
- WPF基礎:在Canvas上繪製圖形Canvas
- 微信小程式 canvas圓角矩形的繪製微信小程式Canvas
- 標準圓形餅圖Python繪製方法Python
- HTML5 Canvas(實戰:繪製餅圖2 Tooltip)HTMLCanvas
- 使用 HTML5 Canvas 實現圓形圖片裁剪並上傳HTMLCanvas
- 原來 Canvas 也能直接繪製圓角矩形了Canvas
- canvas圓形時鐘效果Canvas
- Python中OpenCV劃線、畫圓、橢圓、新增文字等幾何圖形繪製操作PythonOpenCV
- canvas 繪製扇形Canvas
- canvas 繪製文字Canvas
- canvas 繪製矩形Canvas
- 在Canvas中繪製Geojson資料CanvasJSON
- 使用clay.js繪製一棵圓形樹JS
- echarts 繪製圓形進度條帶漸變色Echarts
- canvas繪製流星效果Canvas
- canvas繪製直線Canvas
- canvas lineWidth 繪製原理Canvas
- canvas lineWidth繪製原理Canvas
- canvas 繪製線條Canvas
- 繪製圖形
- iOS 繪製圓角iOS
- CSS 繪製半圓CSS