HTML5 Canvas Rotate Transform Tutorial

Published on January 18th 2011 by Eric Rowell

To rotate the HTML5 Canvas, we can use the rotate() transform method. The rotate transformation requires an angle in radians. To define the rotation point, we need to first translate the canvas context such that the top left corner of the context lies on the desired rotation point. In this tutorial, we've translated the canvas context such that the top left corner of the context is directly on the center of the rectangle, which produces a rotation about the center of the rectangle.

Live Demo and Editor new window

Author Bio

Eric Rowell

Eric Rowell 

Eric Rowell is the creator of KineticJS, the founder of MeteorCharts, the founder and chief editor of Html5CanvasTutorials.com, the author of HTML5 Canvas Cookbook, and a senior web developer at LinkedIn. He really likes robots, and dreams of one day building his own Megazord.

Submit an Article

Hi there! Are you looking to promote your website or boost your brand? With nearly one million unique page views per month, HTML5 Canvas Tutorials is a great place to submit HTML5 canvas related articles to help meet your goals.

comments powered by Disqus