Rotar lienzo HTML método ()
Ejemplos
Girar el rectángulo 20 grados:
JavaScript:
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.rotate(20*Math.PI/180);
ctx.fillRect(50,20,100,50);
var ctx=c.getContext("2d");
ctx.rotate(20*Math.PI/180);
ctx.fillRect(50,20,100,50);
Trate »
Soporte para el navegador
Internet Explorer 9, el método de Firefox, Opera, Chrome y Safari rote soporte ().
Nota: 8 y versiones anteriores de Internet Explorer no son compatibles con el elemento <canvas>.
Definición y Uso
rotar () para girar el dibujo actual.
Nota: La rotación sólo afectará el dibujo después de la finalización de la rotación.
la sintaxis de JavaScript: | .rotate contexto (ángulo); |
---|
parámetro Valor
参数 | 描述 |
---|---|
angle | 旋转角度,以弧度计。 如需将角度转换为弧度,请使用degrees*Math.PI/180 公式进行计算。 实例:如需旋转 5 度,可规定下面的公式:5*Math.PI/180。 |