New topic: 

Change the colour of a string mid sentence.

<http://forums.realsoftware.com/viewtopic.php?t=46402>

         Page 1 of 1
   [ 4 posts ]                 Previous topic | Next topic          Author  
Message        grechcj          Post subject: Change the colour of a string mid 
sentence.Posted: Mon Dec 31, 2012 7:55 pm                         
Joined: Sun Feb 14, 2010 11:19 pm
Posts: 210
Location: Australia                I would like to display a word on a canvas 
in red then the following word in black.
I can change the colour but I need to get the current x and y to continue where 
I left off.

//Draw the first word
g.ForeColor = rgb(255,00,00)
g.DrawString ("Hello ", 100, 100)

//Draw the second word
g.ForeColor = rgb(00,00,00)
g.DrawString ("World",?,?)
   
                             Top                timhare          Post subject: 
Re: Change the colour of a string mid sentence.Posted: Mon Dec 31, 2012 8:19 pm 
                        
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 11932
Location: Portland, OR  USA                x = x + g.StringWidth("Hello ")   
                             Top                npalardy          Post subject: 
Re: Change the colour of a string mid sentence.Posted: Mon Dec 31, 2012 8:20 pm 
                      Real Software Engineer          
Joined: Sat Dec 24, 2005 8:18 pm
Posts: 7636
Location: Canada, Alberta, Near Red Deer                dim x as integer = 100
dim y as integer = 100
//Draw the first word
g.ForeColor = rgb(255,00,00)
g.DrawString ("Hello ", x, y)

x = x + g.StringWidth("Hello ")

//Draw the second word
g.ForeColor = rgb(00,00,00)
g.DrawString ("World",x,y)
      
_________________
My web site Great White Software
RBLibrary.com REALbasic learning  
                             Top                grechcj          Post subject: 
Re: Change the colour of a string mid sentence.Posted: Mon Dec 31, 2012 8:40 pm 
                        
Joined: Sun Feb 14, 2010 11:19 pm
Posts: 210
Location: Australia                Thanks, I was going to resort to that 
solution but thought there might be a property which holds the current 
co-ordinates after drawing (eg. currentX).   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 4 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to