English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
rotate() ist eine Canvas 2D API fügt die Methode zur Rotation in die Transformationsmatrix hinzu. Der Winkelvariable wird ein Uhrzeigersinn-rotation in Grad und als Bruchteil eines Radius angegeben.
Drehen Sie das Rechteck um 30 Grad:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Verwendung der HTML canvas rotate() Methode-Einführung in HTML3codebox.com)</title> </head> <body> <canvas id="myCanvas" width="300" Höhe="150" style="Rand:1px fest gestrichen #d3d3d3"> Ihr Browser unterstützt HTML nicht5 canvas-Tag. </canvas> <script> var c = document.getElementById("myCanvas"); var ctx=c.getContext("2d"); ctx.rotate(10*Math.PI/180); ctx.fillRect(50,50,100,100); </script> </body> </html>Test and see ‹/›
IEFirefoxOperaChromeSafari
Internet Explorer 9and Firefox, Opera, Chrome and Safari support rotate() Method.
Note:Internet Explorer 8 and earlier versions do not support the <canvas> element.
The rotate() method rotates the current drawing.
Note:Rotation will only affect the engineering drawing created after rotation.
JavaScript Syntax: | context.rotate(angle); |
---|
Parameter | Description |
---|---|
angle | Rotation angle, in radians. To convert degrees to radians, please use degrees*Math.PI/180 Formula for calculation. Example: To rotate 5 Degree, can specify the following formula:5*Math.PI/180. |