colour 'include' file wtd

Blitz3D Forums/Blitz3D Beginners Area/colour 'include' file wtd

Is there an 'include' file which somebody may have written for selecting colours

ie instead of having to use

color(255,0,255)
text"magenta"

I could use

color(magenta)
text"magenta"

or color(darkblue)
text"darkblue"

if you get my meaning. I have an include file for keyboard input from Krylar but cant find a similar one for colour

Thanks
Graham

Well, I dont think there is one, but, what you could do is do one yourself and be the first to submit one.

Just how many colours do you want this to work with? There's millions of them! :O

If you only need it for the basic, primary-based colours, it'd take 5 mins to write your own.

no, i just wanted the basics, eg light blue, blue, dark blue for each of the colours

I will write my own, it just makes it simpler when writing text in different colours so I dont have to keep looking the rgb codes up

thanks anyway

Something along the lines of (and I do not have access to Blitz, so I can't check the colours or there may be little syntax errors, sorry -


Function TxtCol(col$)

Select col$

Case "white"
RED=225
GREEN=225
BLUE=225

Case "brilliant"
RED=255
GREEN=255
BLUE=255

Case "black"
RED=0
GREEN=0
BLUE=0

Case "silver"
RED=180
GREEN=180
BLUE=195

Case "red"
RED=225
GREEN=0
BLUE=0

Case "emerald"
RED=0
GREEN=225
BLUE=0

Case "blue"
RED=0
GREEN=0
BLUE=225

Case "yellow"
RED=225
GREEN=225
BLUE=0

Case "magenta"
RED=225
GREEN=0
BLUE=225

Case "orange"
RED=195
GREEN=170
BLUE=0

Case "brown"
RED=80
GREEN=95
BLUE=0

Case "cyan"
RED=0
GREEN=225
BLUE=225

Case "crimson"
RED=80
GREEN=0
BLUE=0

Case "navy"
RED=0
GREEN=0
BLUE=80

Case "green"
RED=0
GREEN=80
BLUE=0

Case "light grey"
RED=150
GREEN=150
BLUE=150

Case "dark grey"
RED=80
GREEN=80
BLUE=80

Default
RED=255
GREEN=255
BLUE=255

End Select

Color RED,GREEN,BLUE

End Function

;Just add more colours as necessary (to improve speed, try to keep most popular colours at the top of the 'Select' list.



So to activate the colours, it should work with:

TxtCol("red")
Text "red"


TxtCol("silver")
Text "silver"

TxtCol("cyan")
Text "cyan"




etc. etc.

Hope this helps!

_______________________________EDIT____________________________

Added code to the Archives... you never know... ;-)

Or you could do it via constants:
Const color_red=$FF0000
Const color_green=$00FF00
Const color_blue=$0000FF
Const color_yellow=$FFFF00

Function Colour(rgb,g=-1,b=-1)
	If g=-1
		Color 0,0,rgb
	Else
		Color rgb,g,b	
	EndIf
End Function

Colour color_red
Text 10,10,"Red"

Colour color_green
Text 10,30,"Green"

Colour color_blue
Text 10,50,"Blue"

Colour color_yellow
Text 10,70,"Yellow"

Colour 255,255,255
Text 10,90,"White"

MouseWait 


thanks guys, thats what I will do sometime this week