I am drawing an image in HTML 5 using canvas in JavaScript. I need to draw it at a rotated angle. I know this can be done by applying rotate(angle) function using the context of the canvas. But I need to do this without rotating the canvas itself.
Kindly suggest possible approach for this if it’s possible.
You can actually draw whatever you want to rotate into an offscreen canvas and draw that into your main canvas. I borrowed this code from a Google IO Talk:
then cache it with:
and in your drawcode:
This is only useful if you have an object that is rotated by an angle only once and is subsequently only subject to transformations.