Last active
August 29, 2015 14:22
-
-
Save Prince781/d1bd889e07d61ba67c26 to your computer and use it in GitHub Desktop.
scale canvas to hidpi
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
| $("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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
enter this in the address bar