HTML5畫布

arc(cx,cy,radius,start_angle,end_angle,direction);javascript

cx  水平座標java

cy  垂直座標canvas

radius  半徑spa

start-angel  圓周起始位置  (配圖詳細解釋)3d

end_angle  弧長 Math.PI是半圓  Math.PI*2是整個圓  0.5爲四分之一code

direction 順、逆時針  false爲順時針,true爲逆時針(決定了圓弧的方向)blog

 JavaScript 代碼:ip

<script type="text/javascript">

var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
cxt.fillStyle="#FF0000";
cxt.beginPath();
cxt.arc(70,18,15,0,Math.PI*2,true);
cxt.closePath();
cxt.fill();

</script>

canvas 元素:element

<canvas id="myCanvas" width="200" height="100" style="border:1px solid #c3c3c3;">
Your browser does not support the canvas element.
</canvas>

畫半圓get

<script type="text/javascript">

    var c=document.getElementById("myCanvas");
    var cxt=c.getContext("2d");
    cxt.fillStyle="#FFFF00";
    cxt.beginPath();
    cxt.arc(200,200,75,0,Math.PI*1.5,true);
    cxt.lineTo(200,200);
    cxt.closePath();
    cxt.fill();
    

</script>

相關文章
相關標籤/搜索