how to change text color?

Posted By: pfeldman

how to change text color? - 08/14/08 03:30

I have a PANEL that looks like this:

PANEL* panDisplay= {
digits(100, 300, "# 1: %0.1f", "Arial#60b", 1, t_1);
digits(450, 300, "# 2: %0.1f", "Arial#60b", 1, t_2);
flags= VISIBLE;
}

t_1 and t_2 are the remaining times for players 1 and 2, respectively. I'd like to change the color of the text to red to warn a player when his time falls below 60 seconds. It seems as though it should be possible to do this using pan_setvar(), but I haven't been able to figure out how, and there are no examples of this. Any advice will be appreciated.

Dr. Phillip M. Feldman
Posted By: EvilSOB

Re: how to change text color? - 08/14/08 07:44

I think you'll need to use one or two TEXT* objects.
Check the manual, but they function very like the digits commands,
but they are separate objects to the panel, so you'll need to position
the TEXT objects over the top of your panel.
Posted By: Scorpion

Re: how to change text color? - 08/14/08 10:00

Code:
vec_set(panDisplay.blue,vector(0,0,255));


or:

Code:
panDisplay.red = 255;
panDisplay.green = 0;
panDisplay.blue = 0;

Posted By: MrGuest

Re: how to change text color? - 08/14/08 15:01

if it's always consistent then set it directly
PANEL* panDisplay= {
digits(100, 300, "# 1: %0.1f", "Arial#60b", 1, t_1);
digits(450, 300, "# 2: %0.1f", "Arial#60b", 1, t_2);
red = 255; green = 0; blue = 0;
flags= VISIBLE;
}
Posted By: EvilSOB

Re: how to change text color? - 08/14/08 21:25

Both Scorp and MrGuest are right but have missed the point that the request
for different lines of the panel have different colors.
The code they supplied will set the color for the text of the whole panel, so
unless you put two separate panels right next to each other it wont help.
Unless of course, I've misunderstood the question and so apologise.
Posted By: DJBMASTER

Re: how to change text color? - 08/15/08 00:15

yeh, i don't believe there is a mechanism that allows you to color digits, or other elements of a panel, individually.

pan_setvar will only set variables, it wont change constants like size, limits, color.

I guess you will have to create 2 seperate objects, unless you can pursuade JCL to add this.
Posted By: LazyDog

Re: how to change text color? - 08/16/08 13:02

instead of using a panel you could use draw_textmode and draw_text.
each draw_text can use it's own color settings.

check them out in the manual.
Posted By: lostzac

Re: how to change text color? - 08/16/08 13:26

I have been following this topic since it started, and you know I never even thought of using draw_text....lol....Thats a good idea and probably the best way of handling something like this. KUDOS to you LazyDog
Posted By: DJBMASTER

Re: how to change text color? - 08/16/08 13:48

personally i would prefer 2 TEXT* objects...

draw_textmode is a slow function and it's not wise to set it lots of times in the same frame.
Posted By: LazyDog

Re: how to change text color? - 08/18/08 23:09

yes draw_textmode is slow, but if you only need to use 1 font then setting this one time before your main loop allows you to use draw_text to change the colors to your hearts delight and draw_text is fast.

so basically it depends on your situation.
© 2024 lite-C Forums