We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
Text object (Read 533 times)
Text object
Apr 15th, 2007, 1:46pm
 
Hello list,
How do you locate the x and y coordinates of the individual letters in a string that is displayed by use of the Text object.
E.g.:
String s = "This is a test";
text(s, 10, 20);
I know that there is textWidth() but it does not account for spacing between letters.
Thanks.
Re: Text object
Reply #1 - Apr 15th, 2007, 1:57pm
 
If you want to know where the second s in "This is a test" try x=10+textWidth("This i",10,20); //The 10+ is because of the 10 in the text()
y=20;
Re: Text object
Reply #2 - Apr 15th, 2007, 2:42pm
 
Thanks for the quick reply.
I used following line of code in a for loop:
char_loc += textWidth(s.charAt(i)); -Whith char_loc being a float variable. That seems to do the trick for now.
Page Index Toggle Pages: 1