Last active
May 29, 2016 04:24
-
-
Save nishinoshake/fdca3441f80ca4e2e48c to your computer and use it in GitHub Desktop.
Canvasを回転させる
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
saveして原点を移動して描画してrestore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var offsetX = item.x + item.width / 2, | |
offsetY = item.y + item.height / 2; | |
ctx.save(); | |
ctx.translate(offsetX, offsetY); | |
ctx.rotate(deg * 180/PI); | |
ctx.translate(-offsetX, -offsetY); | |
ctx.restore(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment