HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Color Codes

08-02-2004, 05:39 PM#1
Ninja73
ok, im wanting 2 make a color code program, however, i dont know what the letters within color codes mean. like |c0080dd56|r the d's represent green, but what shade of it? and how would i convert a 3 didget like 255 into 2 digets like 80?
08-02-2004, 05:49 PM#2
Heptameron
Well, think of it like our number system, except the digits go from 0 to 15 (F) instead of 0 to 9. A, B, C, D, E and F stand for 10, 11, 12, 13, 14 and 15. The number right before is that value multiplied by 16 (similar to our system). So DD equals (13 *16) + 13.
08-02-2004, 05:55 PM#3
Ninja73
k, so i would take the first letter like if it was ac i would take a which would b 10, then multiply that by 16, then add the second letter or c which would b 12, so ac would b 172?
08-02-2004, 06:07 PM#4
R3N3G4D3
this numbering system is called hexadecimal system, the codes used for colors are the same codes used for colors in html (all the webpages), an easy way to convert from decimal to hexadecimal is to divide the number by 16, then take the integer part of the answer, and replace it with corresponding hex digit (if you get 15, replace with F), the multiply the decimal part by 16, and that's your second digit. You can convert back from hex to decimal by taking the number 1 higher than the number corresponding to the first digit of the hex, and multiply it by 16, then substract the amount by which the second digit is less than 16 (for example if you had BF, you do ((11+1)*16)-1 = 191). Also, there are lots of tables online for hex color codes, and there are also already a few programs for colors existing for world editor, in fact I'm sure there are some in "downloads" section on this website, and the colorpicker not only sets the color to what you want, it can also be used to create a color-fade effect by choosing 2 different colors for the beginning and the end of the phrase, so I really don't think it would be worth your time to write yet another color changer program for WC3, since there are already a few good ones.
08-02-2004, 07:11 PM#5
Ninja73
k, thnx, i get it now
08-02-2004, 07:27 PM#6
R3N3G4D3
like I said you take the integer part of the answer and use it for your first hex, and then multiply the fraction part by 16 to get the 2nd hex digit. So 137/16=8.5625, the first digit is 8, .5625*16=9, so its 89 in hex. And hex is just a more compact representation of RGB, in RRGGBB format, so 00 in place of RR would be mean that there is no red used at all for the color, while FF would mean taht maximum amount of red is used.

EDIT: nvm, I started typing this before you got it.
08-02-2004, 07:39 PM#7
Heptameron
Yeah, I believe AC would be 172...

137 to hex: 137 divided by 16, rounded down. If that number is 10, change it to A, if it's eleven, change it to B, etc. That's the first digit. For the second digit, you do this: 137 modulo 16 (remainder of the division 137 / 16).