Blog

Canvas Rotate Method in HTML5

Posted by Mahak Gupta Blogs | HTML 5 Jan 21, 2012
Canvas Rotate Method is used to rotate the Canvas.
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




COMMENT USING
PREMIUM SPONSORS
Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.
SPONSORED BY
  • MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.
Employers - Post Free Jobs