Created
April 16, 2014 07:12
-
-
Save vmus/1867d1a7003006c6dd3b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var canvas = document.getElementById("myCanvas"); | |
var context = canvas.getContext("2d"); | |
// if backingStorePixelRatio is less than devicePixelRatio, everything needs to be scaled up | |
var ratio = (context.webkitBackingStorePixelRatio < window.devicePixelRatio) ? (window.devicePixelRatio || 1) : 1; | |
if (ratio > 1) { | |
canvas.width *= ratio; | |
canvas.height *= ratio; | |
context.scale(ratio, ratio); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment