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.
IndexProgramming Questions & HelpSyntax Questions › Change color / styling of text mid-string
Page Index Toggle Pages: 1
Change color / styling of text mid-string? (Read 211 times)
Change color / styling of text mid-string?
Jan 22nd, 2009, 7:56am
 
I'd like to change the color of my text mid-string.  Specifically, I'd like display a certain keyword in red every time it appears.  So let's say the word "bob" appears twice in the string tweet[i] -- how do I make "bob" red and the rest of the text blue?  

text(tweet[counter], 200, 150, 500, 200);

(I don't want to have to use a mono-spaced font, and I want my text to wrap, so I'm specifying a width and height for the text area)

Thanks!
Re: Change color / styling of text mid-string?
Reply #1 - Jan 22nd, 2009, 2:08pm
 
Unfortunately I think you have to do it by hand.

textWidth will tell you the width of a given string to make positioning easier (so you don't have to use monospaced), but you'll ahve to handle multiple lines etc yourself AFAIK.
Page Index Toggle Pages: 1