Last active
February 16, 2024 07:23
-
-
Save vicro/5829162 to your computer and use it in GitHub Desktop.
Retina Display for CreateJS
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, stage, exportRoot; | |
function init() { | |
canvas = document.getElementById("canvas"); | |
//Setup the canvas widht and height with devicePixelRatio. And set CSS width and height properties. | |
var w = 320; | |
var h = 357; | |
canvas.width = w * window.devicePixelRatio; | |
canvas.height = h * window.devicePixelRatio; | |
canvas.style.width = w + "px"; | |
canvas.style.height = h + "px"; | |
exportRoot = new lib.myAnimation(); | |
stage = new createjs.Stage(canvas); | |
//Scale up the content for retina displays using devicePixelRatio. | |
stage.scaleX = window.devicePixelRatio; | |
stage.scaleY = window.devicePixelRatio; | |
stage.addChild(exportRoot); | |
stage.update(); | |
createjs.Ticker.setFPS(16); | |
createjs.Ticker.addListener(stage); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!