0

How to get graphics object width or text width using createjs or easeljs.

Graphics Obj : 

var myShape = new createjs.Shape();
myShape .graphics.beginStroke("#FFFFFF");
myShape .graphics.setStrokeStyle(5);
myShape .graphics.beginFill("#C1272D").drawRect(0, 0, gameStage.canvas.width - 10, 40);
stage.addChild(myShape);

Text Field :

var textF = new createjs.Text("Time Left.. Do it Fast", "20px Arial", "#FFFFFF");
stage.addChild(textF);

How can I retrieve the dimensions (width & height) of textF and myShape?

olsn
  • 16,644
  • 6
  • 59
  • 65
Harish Patidar
  • 303
  • 4
  • 13

1 Answers1

0

There is (currently) no way of getting a calculated way of a Shape, implementing this in JavaScript would be way to slow.

The dimensions of a text can be retrieved via: getMeasuredWidth() and getMeasuredHeight() http://www.createjs.com/Docs/EaselJS/classes/Text.html

olsn
  • 16,644
  • 6
  • 59
  • 65
  • You can do this yourself but for performance reasons the is no generic way of calculating the dimensions of a Shape – olsn Jun 27 '13 at 09:08