Skip to content

Instantly share code, notes, and snippets.

@vmus
Created April 16, 2014 07:12
Show Gist options
  • Save vmus/1867d1a7003006c6dd3b to your computer and use it in GitHub Desktop.
Save vmus/1867d1a7003006c6dd3b to your computer and use it in GitHub Desktop.
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