Skip to content

Instantly share code, notes, and snippets.

@vicro
Last active February 16, 2024 07:23
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vicro/5829162 to your computer and use it in GitHub Desktop.
Save vicro/5829162 to your computer and use it in GitHub Desktop.
Retina Display for CreateJS
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);
}
Copy link

ghost commented Apr 18, 2017

what if I use images

@kornilova203
Copy link

Thanks!

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