Dark Bit Factory & Gravity
PROGRAMMING => Other languages => Blitz => Topic started by: lilw4t3rdr0p on December 21, 2006
-
Is it possible to get anything beside neon colors?
I want a dark green, or at least something closer to a true green.
And maybe some pastels. I have been playing for sometime and can't seem to hit the colors I want.
HELP!!!! please! :)
-
A tip: If you have a Graphics Package you can get the colour values from the palette / Swatch. Also remember the order is Red, Green, Blue.
-
When you use WritePixel, there is a number at the end which is the colour.
You probably know colours like
$ffffffff = white
$ffff0000 = red
$ff00ff00 = green
$ff0000ff = blue
What you need to know is hexadecimal numbers, and the way to put them together into the colour.
First, each colour component, red, green, blue, is a sliding scale from 0 (off) to 255 (full on).
So to make a dark green, you might have 0 blue, 0 red and 100 green (just under half intensity).
Or to make pink, you might want a lot of red, and some green and some blue, say 255,200,200.
You can make any colour you like.
Now you need to know how to make those magic hexadecimal (hex) values $xxxxxxxx
Each pair of xs of that hexadecimal number represents a bit of the colour, and it looks like this
$AARRGGBB
Where AA is alpha, the transparency part, RR is red, GG is green, BB is blue.
Don't worry about the alpha right now. We'll just set it to be totally not transparent. It only works in a few cases anyway.
So, how do we get from 255,200,200 to $ffRRGGBB? We need to convert the decimal values into hex.
One way of doing this is with Windows Calculator.
StartMenu->Accessories->Calculator.
Then go into the View menu and select Scientific - it's the 2nd option down.
Now, for each of the colour values, click the Dec button, type in the number and then click the Hex button.
So
Dec.
255
Hex
FF
Dec
200
Hex
C8
Dec
200
Hex
C8
That gives you FFC8C8
And the full colour with alpha as FF is
$FFFFC8C8
Try it with some other colours.
If you would like hexadecimal explained properly, let me know.
Have fun! (And please post up your starfield in the other thread!)
Jim
-
Jim...
That went completely over my head.
This is what I was taught:
; Set Color
Color red, green, blue
AKA: Color 250, 24, 90
That is the only way I know how to do color.
I figured out how to change the color of the background and it is fine, but everything is this aweful neon shades.
-
The instructions I was (trying!) to give are for WritePixel where the colour value looks like a magic value. I was using WritePixel to do the stars in my example that I gave you.
Which command are you using? You obviously know how to make colours out of R G and B and put them in to the Color command. Can you post the code (or a snippet) which shows the problem?
Jim
-
If you want dark colours ( sorry Im English ;) ) use lower values, and if you want brighter use higher values. Each individual color component ( R, G, B ) go in the Range 0-255. Zero being the off switch. 255 the brightest of them all.
So say your after a dark green. You'd do use a value like.
Color 000,064,000 ; No Red, A bit of Green, No Blue.
-
Thanks Cylde.... The colours ;) are better!
-
if you want pastel colors (I'm english, but have been using blitz for too long), then make the colour you want 255, and make the remaining two around 150-180 ish. For example, pastle red could be 255,160,160 you see?
-
Thanks slinks!!
-
No worries lilw4t3rdr0p.
What Jim has nicely shown is the way you'd incorparate using colors with the WritePixel / WritePixelFast commands. As you'll need to convert the colors values of (0-255) into a different format called Hex which goes from 0-9 and as theres no 10 the next character is an A, and goes as far as F . Which Im sure your be onto pretty soon.
-
LOL. Oh okay. I get it now. Thanks Clyde.... and THANK YOU JIM!!!
-
Just thought I'd add something to this, hopefully this might make some sense:
base 10 (decimal) 0-9
base 16 (hexadecimal) 0-9 then A-F
DEC HEX
0 0
1 1
2 2
... ...
9 9
10 A
11 B
12 C
13 D
14 E
15 F
16 10
17 11
... ...
30 1E
31 1F
32 20
33 21
... ...
255 FF
this is useful when using hex values for colors, the 6 digit number can be broken up into 3 pairs (there is alpha that jim mentioned too which may have to be set to FF in blitz):
RRGGBB
so white=FFFFFF=FF(red part),FF(green part),FF(blue part)
which in decimal is 255,255,255 (255 is the max value for each red/green/blue part)
or
red = FF0000
green = 00FF00
blue = 0000FF
and if you wanted to mix a little bit of blue with a lot of red you'd have something like
FF004A
EDIT:
Ah sorry, I just read your second post again and realised this isn't quite what you're after but i'll leave it.
-
No, it actually helped! So thank you!
-
np, I did write something there though that isn't quite right.
when i said in decimal it is 255,255,255 i meant that each part of the color has a value of 255 but to write the whole thing down as one decimal number is a bit different and in this case it would be 16777215 and has less meaning than the hex equivelant and is more difficult to work with.