Canvas Rotate Method in HTML5
Canvas Rotate Method is used to rotate the Canvas. It takes a parameter radians. We can set the degree of rotation by using the formula:
For 10 degree:
10 * PI/180
- <html><body><canvas id="myfirstcan" width="200" height="100" style="border:2px solid #FF00FF;">
- CANVAS</canvas><script type="text/javascript">
- var canv=document.getElementById("myfirstcan");
- var x=canv.getContext("2d");
- x.rotate(10*Math.PI/180);
- x.fillRect(20,30,100,20);
- </script></body></html>