Skip to content

Instantly share code, notes, and snippets.

@justin-c-rounds
Created November 24, 2011 15:35
Show Gist options
  • Save justin-c-rounds/1391608 to your computer and use it in GitHub Desktop.
Save justin-c-rounds/1391608 to your computer and use it in GitHub Desktop.
Drawing image to canvas
function drawImage(context, sprite) {
context.save();
context.translate(sprite.x, sprite.y);
context.rotate(sprite.rotation * (Math.PI / 180));
context.globalAlpha = sprite.opacity;
context.drawImage(sprite.image, -sprite.pivotX, -sprite.pivotY, sprite.width, sprite.height);
context.restore();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment