3 回答
TA貢獻2條經驗 獲得超1個贊
<html>
<head>
<title>
畫
</title>
?<script>
function ?circle(){
? ? ? ? var canvas=document.getElementById('canvas');
? ? ? ? var cxt=canvas.getContext('2d');
? ? ? ? cxt.lineWidth=3;
? ? ? ? cxt.strokeStyle="black";
? ? ? ? cxt.arc(200,200,50,0,Math.PI*2,true);//x坐標,y坐標,半徑,起始角度,結束角度,畫法方向?
? ? ? ? cxt.closePath();
? ? ? ? cxt.stroke();
}
</script>
</head>
<body onload="circle()">
<canvas width="500" height="500" style="background:yellow" id="canvas">
? ?您的瀏覽器不支持該標簽
</canvas>
</body>
</html>
//你把那個360換成Math.PI*2 ? 這個是弧度數就可以了畫出圓了 ?
// true是指順時針進行畫圖 ?具體原因我也不太了解 ?加油吧
TA貢獻2條經驗 獲得超1個贊
補充:說錯了true是逆時針而false是逆時針 ?
你用的360換算成弧度值其實是2.0幾
就是從false顯示的不完整圓 的左下角開始畫順時針畫到0出也就是正X軸方向
不完整的圓就出來了
最后推薦使用弧度就是Math.PI ?這是π表半圓
<html>
<head>
<title>
畫
</title>
?<script>
function ?circle(){
? ? ? ? var canvas=document.getElementById('canvas');
? ? ? ? var cxt=canvas.getContext('2d');
? ? ? ? cxt.lineWidth=3;
? ? ? ? cxt.strokeStyle="black";
? ? ? ? cxt.arc(200,200,50,0,Math.PI*2,false);//x坐標,y坐標,半徑,起始角度,結束角度,畫法方向?
? ? ? ? cxt.stroke();
}
</script>
</head>
<body onload="circle()">
<canvas width="500" height="500" style="background:yellow" id="canvas">
? ?您的瀏覽器不支持該標簽
</canvas>
</body>
</html>
- 3 回答
- 1 關注
- 1755 瀏覽
添加回答
舉報
