By Nexinarus <http://hybd.net/~mms>
In QBASIC using any screen mode with more than 16 colors there seems to be a randomly organised set of colors that are quite hard to remember.
Here are the base 16 colors of EGA:
As you can see they are not exactly laid out in any normal manner you will see at an art class in school, and can seem very random and hard to remember any colors. But, They are not random at all. If you look at them the second half is basically the first half but brighter.
Here is how to split the colors up into their components:
What I'm trying to say is, to get your colors you "mix" the components to get the final color value.
For example blue is color 1, red is color 4. Blue mixed with red creates purple, so 1 + 4 = 5. So color 5 is the color of purple. To create bright purple, we add purple + white: (1 + 4) + 8 = 13. So color 13 is bright purple. To have black simply do not add any values, as black in space is no light at all, get it?.
In the 16 base colors there are 4 greyscale colors: 0, 7, 8, and 15. 0 is black, 7 is grey, 8 is white, and 15 is bright grey or bright white and this makes perfect sense: bright black (0 + 8, color 8) is the darkest grey, and color 7 is the average grey. Bright grey (7 + 8) creates the brightest white there is, and for this color we will look closer: We have red + green + blue + white (1 + 2 + 4 + 8) to make color 15 (or bright white), which is ALL of the 4 components of the 16 base colors. Seem easy? Get it? I hope this helped explain why IBM or whoever chose those seemingly ridiculous color scheme!
Continuing on with some code we can define constants to show a real example:
'color components CONST blue = 1, green = 2, red = 4, white = 8 'prepare SCREEN 0 'text mode with EGA colors CLS 'clear screen 'show each component COLOR red + green + blue + white PRINT "Components:" COLOR blue PRINT "blue "; COLOR green PRINT "green "; COLOR red PRINT "red "; COLOR white PRINT "white!" PRINT 'show some mixes of colors COLOR red + green + blue + white PRINT "Color mixes:" COLOR blue + green PRINT "Cyan, color of the sky." COLOR green + red + white PRINT "Yellow, color of the sun." COLOR blue + red PRINT "Purple, color of pimp." COLOR blue + red + white PRINT "Bright purple, color of the mac-daddy pimp." PRINT 'show greyscale colors COLOR red + green + blue + white PRINT "Greyscales:" COLOR 0, blue 'set black as foreground, blue background so black is visible PRINT ">> "; COLOR white PRINT ">> "; COLOR red + green + blue PRINT ">> "; COLOR red + green + blue + white PRINT ">> " PRINT COLOR , 0