Skip to content

Instantly share code, notes, and snippets.

@naotone
Created May 8, 2013 12:29
Show Gist options
  • Save naotone/5540125 to your computer and use it in GitHub Desktop.
Save naotone/5540125 to your computer and use it in GitHub Desktop.
Optimize html5 canvas for retina display.
retinaCanvas = ->
if window.devicePixelRatio > 1
canvas.width = W * window.devicePixelRatio
canvas.height = H * window.devicePixelRatio
ctx.scale(window.devicePixelRatio, window.devicePixelRatio)
else
canvas.width = W
canvas.height = H
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment