How to put RGB value into variable?

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.

I want something like the code below.

Is there any way to do this?

Code: Select all

if true 
  variable=RGB(0,200,0)
else
  variable=RGB(0,0,0)
endif
frontcolor(variable)

Using Windows 98 SE
Registered PB version : 3.2 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.

Check the 'Misc' library in the reference manual, there is all you want to know!
you could do it like this:

Code: Select all

if true 
  variable=RGB(0,200,0)
else
  variable=RGB(0,0,0)
endif
frontcolor(Red(variable),Green(variable),Blue(variable))
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.

Thanks Pupil,

I overlooked it

Using Windows 98 SE
Registered PB version : 3.2 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tinman.

A lot of the drawing commands also have an optional color parameter, so instead of using:

Code: Select all

FrontColor(Red(variable), Green(variable), Blue(variable))
Plot(x,y)
You can do this:

Code: Select all

Plot(x,y,variable)
Doing it like this is quicker (well, for plotting anyway :wink: in some cases, and if the drawing commands you are using support it, it may be worth a look.


--
It's not minimalist - I'm increasing efficiency by reducing input effort.
(Win98first ed. + SP1, PB3.20)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by cor.

It would be nice if Drawtext has the color option, just like circle.

So, Fred would it be possible to add color options to all drawing commands?

Using Windows 98 SE
Registered PB version : 3.2 (Windows)
--------------------------
C. de Visser
Author of Super Guitar Chord Finder
http://www.ready4music.com
Post Reply