Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function drawImageRot(ctx,img,x,y,width,height,rad){
- //Convert degrees to radian
- //var rad = deg * Math.PI / 180;
- //Set the origin to the center of the image
- ctx.translate(x + width / 2, y + height / 2);
- //Rotate the canvas around the origin
- ctx.rotate(rad);
- //draw the image
- ctx.drawImage(img.getImage(),width / 2 * (-1),height / 2 * (-1),width,height);
- //reset the canvas
- ctx.rotate(rad * ( -1 ) );
- ctx.translate((x + width / 2) * (-1), (y + height / 2) * (-1));
- }
Advertisement
Add Comment
Please, Sign In to add comment