seinecle
seinecle

Reputation: 10778

how to measure text width in kineticjs?

Is there a method or workaround to return the text width of a string in a Text Shape, in KineticJs?

I would need it to position precisely the TextShape on the canvas.

Upvotes: 5

Views: 2101

Answers (2)

Rich
Rich

Reputation: 315

Kinetic.Text has getTextHeight() and getTextWidht() methods to do this for you.

Upvotes: 9

jaker
jaker

Reputation: 7840

This might help you. It demonstrates how to get the width of some text. There is also a link to another example showing how to do this for multi-line text, here.

Upvotes: 4

Related Questions