3 回答

TA貢獻(xiàn)2條經(jīng)驗(yàn) 獲得超1個(gè)贊
<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坐標(biāo),y坐標(biāo),半徑,起始角度,結(jié)束角度,畫法方向?
? ? ? ? cxt.closePath();
? ? ? ? cxt.stroke();
}
</script>
</head>
<body onload="circle()">
<canvas width="500" height="500" style="background:yellow" id="canvas">
? ?您的瀏覽器不支持該標(biāo)簽
</canvas>
</body>
</html>
//你把那個(gè)360換成Math.PI*2 ? 這個(gè)是弧度數(shù)就可以了畫出圓了 ?
// true是指順時(shí)針進(jìn)行畫圖 ?具體原因我也不太了解 ?加油吧

TA貢獻(xiàn)2條經(jīng)驗(yàn) 獲得超1個(gè)贊
補(bǔ)充:說錯(cuò)了true是逆時(shí)針而false是逆時(shí)針 ?
你用的360換算成弧度值其實(shí)是2.0幾
就是從false顯示的不完整圓 的左下角開始畫順時(shí)針畫到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坐標(biāo),y坐標(biāo),半徑,起始角度,結(jié)束角度,畫法方向?
? ? ? ? cxt.stroke();
}
</script>
</head>
<body onload="circle()">
<canvas width="500" height="500" style="background:yellow" id="canvas">
? ?您的瀏覽器不支持該標(biāo)簽
</canvas>
</body>
</html>
- 3 回答
- 1 關(guān)注
- 1727 瀏覽
添加回答
舉報(bào)