FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Discussion
   General Processing Discussion
(Moderators: fry, REAS)
   centered dynamic text
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: centered dynamic text  (Read 314 times)
pollux

WWW Email
centered dynamic text
« on: Apr 2nd, 2003, 1:00am »

well, i need to display some changing text (sort of a countdown) always centered on the screen.  
 
any ideas?
« Last Edit: Apr 2nd, 2003, 1:11am by pollux »  

pollux | www.frwrd.net
fry


WWW
Re: centered dynamic text
« Reply #1 on: Apr 2nd, 2003, 3:16am »

i don't particularly like this part of the api, but this is it for now:
Code:
BFont font = loadFont("blah.vlw.gz");
setFont(font, 12);
String thetext = "center me";
//font.charWidth('1') also works
int wide = font.stringWidth(thetext);
text(thetext, width/2 - wide/2, height/2);

i'd like to add a textMode(CENTERED) or something like that. it shouldn't require this much thought.
 
pollux

WWW Email
Re: centered dynamic text
« Reply #2 on: Apr 3rd, 2003, 8:15am »

thanxs fry, saved my life just in time.
btw, nice work this P5 (and most of the stuff i've seen on your website).
 

pollux | www.frwrd.net
Pages: 1 

« Previous topic | Next topic »