Archive for July 25th, 2004

inverse color

while working on my new store script, i learned about inverse color. The inverse of a color is the most contrasting color of that color.

[geektalk] Mathematically, it’s the complement of current RGB value of the color. On the web, each color is represented in either a HEXCODE or its RGB (red, green, blue) form. The hexcode is a representation of the color’s RGB value. Hex means base 16. It’s consisted of 1-9 Plus A-F. Since two hex code can represent up to 256 decimals because 162 = 256 (representing 0 - 255), the first two digit of the hexcode is the color’s red value. The second is the green value and third is the blue value. So after we convert the hexcode representation of the color to its respective red, green and blue values and substract each from 255. Then convert them back to hex and concatenate them. We get its complement color or inverse.[/geektalk]

Either way, if you don’t know what I’m talking about, just take a look at this example. You will get it.

in my scripts collection, i also give you a php function which is 10 times easier to write than the javascript version of it.