Blog

Canvas Rotate Method in HTML5

By Mahak Gupta Jan 21 2012
Canvas Rotate Method is used to rotate the Canvas.
    • Like
    • Love It
    • Awesome
    • Interesting
    • It's Okay
    • Thumbs Down
  • 3.5k
  • 0
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>



1234565.png