Canvas rotate() 方法
定义和用法
rotate()
方法旋转当前的绘图。
实例
将矩形旋转 20 度:
JavaScript:
var c=document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.rotate(20*Math.PI/180); ctx.fillRect(50,20,100,50);
语法
context.rotate(angle);
参数值
参数 | 描述 |
---|---|
angle |
旋转角度,以弧度计。 如需将角度转换为弧度,请使用 degrees*Math.PI/180 公式进行计算。 Example: To rotate 5 degrees, you can specify the following formula: 5 * Math.PI / 180. |
Browser support
The numbers in the table indicate the first browser version that fully supports this property.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
4.0 | 9.0 | 3.6 | 4.0 | 10.1 |
Note:Internet Explorer 8 and earlier versions do not support the <canvas> element.