Created
November 24, 2011 15:35
-
-
Save justin-c-rounds/1391608 to your computer and use it in GitHub Desktop.
Drawing image to canvas
This file contains 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
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