JSFiddle - React, Tailwind, and code Playground

by Mehmet Demiray

HTML

<canvas id="test" width="500" height="300"></canvas>

JavaScript

var stage = new createjs.Stage("test");

var p = new createjs.Container();
p.x = 200;
p.y = 200;

var c1 = new createjs.Shape();
c1.graphics.beginFill("#FF0000");
c1.graphics.drawRect(0, 0, 100, 100);
c1.graphics.endFill();

var c2 = new createjs.Shape();
c2.graphics.beginFill("#00FF00");
c2.graphics.drawRect(0, 0, 100, 100);
c2.graphics.endFill();
c2.x = 100;

p.addChild(c1);
p.addChild(c2);

stage.addChild(p);

stage.update();

var pt = p.localToGlobal(c2.x, c2.y);
alert("Stage x of c2: " + c2.x);
alert("Stage x of c2: " + pt.x);