Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 851
seinecle Avatar asked Oct 02 '12 18:10

seinecle


2 Answers

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

like image 161
Rich Avatar answered Oct 17 '22 04:10

Rich


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.

like image 4
jaker Avatar answered Oct 17 '22 04:10

jaker