Skip to content

Instantly share code, notes, and snippets.

@Prince781
Last active August 29, 2015 14:22
Show Gist options
  • Save Prince781/d1bd889e07d61ba67c26 to your computer and use it in GitHub Desktop.
Save Prince781/d1bd889e07d61ba67c26 to your computer and use it in GitHub Desktop.
scale canvas to hidpi
$("canvas").each(function(i,elem) { var ctx = elem.getContext('2d'); var ratio = (window.devicePixelRatio || 1) / (ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1); elem.width *= ratio; elem.height *= ratio; ctx.scale(ratio,ratio); }); void(0);
@Prince781
Copy link
Author

enter this in the address bar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment