Color

Post your coding questions such as 'how to' here.
Post Reply
coolw
Newcomer
Posts: 39
Joined: Wed Aug 29, 2007 11:17 pm
Location: West Virginia
Contact:

Color

Post by coolw »

How do I set the Text color, not the Drawing color (i.e. not like

Code: Select all

Color cbblack
)?
My car game! (WIP)
viewtopic.php?f=18&t=53

Code: Select all

Coolw is the best! :)
koodaaja
Moderator
Moderator
Posts: 1583
Joined: Mon Aug 27, 2007 11:24 pm
Location: Otaniemi - Mikkeli -pendelöinti

Re: Color

Post by koodaaja »

Text is drawn with the current drawing color, so you must change the drawing color to get the text color to change.
coolw
Newcomer
Posts: 39
Joined: Wed Aug 29, 2007 11:17 pm
Location: West Virginia
Contact:

Re: Color

Post by coolw »

Oh, ok thanks! You sure there isn't any other way? Oh and Zero, it would be a good idea in the next version of CB to make it so that text has its own color, not the drawing color :)
My car game! (WIP)
viewtopic.php?f=18&t=53

Code: Select all

Coolw is the best! :)
koodaaja
Moderator
Moderator
Posts: 1583
Joined: Mon Aug 27, 2007 11:24 pm
Location: Otaniemi - Mikkeli -pendelöinti

Re: Color

Post by koodaaja »

Well, if you need to restore the color you used before the text, use this:

Code: Select all

r = geRGB(RED)
g = getRGB(GREEN)
b = getRGB(BLUE)
Color cbblack
Text x, y, "text"
color r, g, b
But if you would just like to decrease the amount of rows by not changing the color all the time, its not possible.
Harakka
Advanced Member
Posts: 430
Joined: Mon Aug 27, 2007 9:08 pm
Location: Salo
Contact:

Re: Color

Post by Harakka »

You can have many texts with different colors on the screen at the same time.

Code: Select all

Repeat
  Color cbBlue
  Text 0,0,"cbBlue"
  Color cbRed
  Text 0,13,"cbRed"
  Color cbYellow
  Text 0,26,"cbYellow"
  Color cbGreen
  Text 0,39,"cbGreen"
  Color cbSilver
  Circle 70,5,50,1
  Text 130,25,"cbSilver"
  DrawScreen
Forever
EDIT: Added a circle to the example.
Peli piirtokomennoilla - voittaja, Virtuaalilemmikkipeli - voittaja,
Sukellusvenepeli - voittaja, Paras tileset - voittaja
Vaihtuva päähenkilö - voittaja, Autopeli - voittaja sekä
Hiirellä ohjattava peli - voittaja B)
User avatar
Zero
Lead Developer
Lead Developer
Posts: 727
Joined: Sun Aug 26, 2007 2:30 pm
Location: Helsinki, Finland
Contact:

Re: Color

Post by Zero »

I really don't see why would it be necessary to add another parameter to existing Text commands OR adding a "TextColor r,g,b". However I will think about it as CoolBasic is now being redesigned. You won't be seeing this feature in the current generation, though.
CoolBasic henkilökuntaa
Johtava Suunnittelija
CoolBasic V3, CoolBasic Classic

http://www.coolbasic.com/blog
coolw
Newcomer
Posts: 39
Joined: Wed Aug 29, 2007 11:17 pm
Location: West Virginia
Contact:

Re: Color

Post by coolw »

Well I think it would be nice, mostly because you could have text in one color and then drawings (I.E. Lines, Boxes, ext.) in a different color.
My car game! (WIP)
viewtopic.php?f=18&t=53

Code: Select all

Coolw is the best! :)
User avatar
Dibalo
Advanced Member
Posts: 298
Joined: Mon Aug 27, 2007 8:12 pm
Location: Espoo, Finland
Contact:

Re: Color

Post by Dibalo »

Of course you can change the color before drawing each individual primitive or text. It adds few lines but I think it´s more clear than setting own color for primitives and text separately. It can be a little bit confusing for newbies if the text and primitives have their own drawing color.

Here is an example I mean by saying to change the drawing color before each primitive and text:

Code: Select all

Color 255,0,0
Box 0, 0, 200, 20
Color 0,0,255
Box 5,2,190,16
Color 255,255,255
CenterText 100, 10, "Hello, World!", 2

DrawScreen
WaitKey
The darkest spells can be found from
http://tunkkaus.blogspot.fi
Post Reply