Skip to content

Instantly share code, notes, and snippets.

@nishinoshake
Last active May 29, 2016 04:24
Show Gist options
  • Save nishinoshake/fdca3441f80ca4e2e48c to your computer and use it in GitHub Desktop.
Save nishinoshake/fdca3441f80ca4e2e48c to your computer and use it in GitHub Desktop.
Canvasを回転させる
saveして原点を移動して描画してrestore
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