I have a canvas on which the user can draw with some sort of pen.
The canvas height is slightly larger than the width. The actual size depends on several variables.
I want to give the user the ability to rotate his/her drawing.
I’m creating a new canvas on which i draw the old canvas rotated.
Below is how i did 180 degrease.
if(rotation==180){
ctx.translate(canvas.width/2, canvas.height/2);
ctx.rotate(Math.PI);
ctx.translate(-canvas.width/2, -canvas.height/2);
ctx.drawImage(drawing,0,0);
}
Now for the 90 degrease I also have to do a resize because otherwise it won´t fit anymore.
I’m not even sure where to start. Any ideas on how to do this?
See this posts
HTML5 canvas image rotate left rotate right
http://phptechworld.blogspot.in/2012/10/html5-canvas-image-rotation.html