该arc()
方法用于使用canvas元素在HTML5中创建一个圆。对于带arc()
方法的圆,将起始角度设为0,将终止角度设为2 * Math.PI。
这是方法的参数值arc()
-
S.没有 | 参数 | 描述 |
1 | X | x坐标 |
2 | ÿ | y坐标 |
3 | [R | 圆半径 |
4 | startingAngle | 弧度起始角 |
5 | 结尾角度 | 结束角(弧度) |
6 | 逆时针(True / False) | 对于逆时针绘图,请选择“真”,否则选择“假” |
您可以尝试运行以下代码以使用arc()
HTML5中的方法绘制圆-
<!DOCTYPE html> <html> <head> <title>HTML Canvas</title> <head> <body> <canvas id="newCanvas" width="300" height="150" style="border:1px solid #000000;"></canvas> <script> var c = document.getElementById("newCanvas"); var ctxt = c.getContext("2d"); ctxt.beginPath(); ctxt.arc(100,75,50,0,2*Math.PI); ctxt.stroke(); </script> </body> </html>