Skip to content

Instantly share code, notes, and snippets.

@positlabs
Created February 7, 2013 19:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save positlabs/4733350 to your computer and use it in GitHub Desktop.
Save positlabs/4733350 to your computer and use it in GitHub Desktop.
canvas image rotation
/*
@param originx, originy - percentage values
*/
function drawImageRot(ctx, img, x, y, width, height, radians, originx, originy) {
ctx.save();
ctx.translate(x, y);
ctx.rotate(radians);
ctx.drawImage(img, -originx * width, -originy * width, width, height);
ctx.restore();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment