javascript - HTML5 canvas drawImage with at an angle -


I & lt; Canvas & gt; I am experimenting with animation and how to remove it. An image at an angle is the desired effect. Some images are normally created, in which one image rotates slowly (this image is at the center of the screen. No, it does not matter if it does not matter).

you need

Consider image points in a HTMLImageElement object.

  var x = canvas.width / 2; Var y = canvas Height / 2; Var width = image.width; Var height = image.height; Context.translate (x, y); Context.rotate (angleInRadians); Context.drawImage (image,-method / 2, -high / 2, width, height); Context.rotate (-angleInRadians); Context.translate (-x, -y);  

The X, Y coordinate is the center of the image on the canvas.


Comments