As: Rgb 2006-07-11 14:41:51
What is RGB?
RGB stands for Red Green Blue. It is how colours are made on your computer. In real life, there are 3 primary colours; yellow, blue and red. Combining these colours can make any colour. On a computer, there are red, green and blue. Similarly, combining these colours can make any colour. In Flash, if you open up your colour pallet underneath the colour you will see a textbox labelled 'Hex'. Another word for RGB is Hexidecimal.
What will I Learn?
You will learn how to write RGB / Hexidecimal values without having to look at your colour pallet.
It is always good to know how things work. When using Flash, you don't ever NEEEED to know how to write Hex, but it's good to know what your doing. Also, you may find yourself someday coding something, and you don't have a colour pallet! Luckily, you will have learned how to program Hex already.
- Metric System -
In the Metric System (the way numbers are formed), each digit can have one of 10 values...
0, 1, 2, 3, 4, 5, 6, 7, 8, 9
In RGB, each digit can have one of 16 values...
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
A = 10, B = 11, C = 12, D = 13, E = 14, F = 15.
- Forming a Hex Value -
A Hexidecimal Value always has 6 digits. The first two stand for the red, the second two stand for the green, and the third two stand for the blue, hence the name RGB. Hex values always have a '#' infront of them, and a '0x' in Actionscript.
- Setting the Values -
So, start off with 0 values...
Now, lets break it down...
00 00 00
If I want to add one to red, I would go like this...
If I wanted to add nine to red, I would go like this...
If I wanted to add ten to red, I would go like this...
Get it? Now, as long as the red value is less than 16, I won't need to fill the first digit of red. Just like in the Metric System, you don't have to fill the tens column until there is more than 9.
0F0000 - This is 15 red.
Once I add more to red, it starts over, and ticks one in the first digit.
100000 - This is 16 red.
The most you can give to red is 256, which is expressed like this.
Here are some more examples of red...
000000 - 0 red, 0A0000 - 10 red, 400000 - 60 red.
The total six digits are just the combination of the 2 reds, the 2 greens, and the 2 blues.
010101 - one red one green one blue.
In RGB, if you have the full amount of all the colours...
You get white. If you have no colours at all...
You get black. If all you have is red...
You get pure red. Similarly with the other colours...
00FF00 - pure green, 0000FF - pure blue.
By just using the different combinations of pure colours, you can get 8 different pure colours...
FFFFFF - white, 000000 - black, FF0000 - red, 00FF00 - green, 0000FF - blue, FFFF00 - yellow, FF00FF - pink, 00FFFF - cyan
Now that you know how to make colours, you just need to know how to add white and add black to those colours; which is easy! If FFFFFF is all white, and 000000 is all black, you just add equally to all colours to brighten it, and subtract equally from all colours to darken it. For example...
FF0000, here is pure red. I want to make it darker, so I'm going to subtract 10 (A) from all colours. I get...
FE0000, which is a small difference. If I want to drastically make it darker, I can subtract, say, half of it.
880000, that is a dark red. Remember, the other digits stay the same because I cannot subtract from them when they are already 0.
0DD082 - That is a terquoise colour. In this instance, if I want to make it darker, I CAN subtract from all colours. I'll subtract 05.
08EA7C - That is the same colour, but darker. If I wanted to brighten the original colour, I could add to all, say, 05.
0FFF83 - That is a brighter version of the same colour.
- - - - - - - - - -
So by now you should be able to make your own colours. Good luck!