zero-perfoliate
zero-perfoliate

Author Topic: RGB to Hex and Hex to RGB  (Read 1432 times)

hotnoob

  • Guest
RGB to Hex and Hex to RGB
« on: December 10, 2009, 05:56:49 PM »
Red, Green, Blue to hexidecial colors!

http://phpbar.isgreat.org/viewtopic.php?f=4&t=8

Here is an example on how to use it^^^:

Code: [Select]
    function displayMessage(color) // ive removed all vars and functions not related to this example..
       {
       if(empty(color))
       {
         color = "EAE8FF";
       }
       color = color.replace("#", ""); //substr(-6); has problems as well as some other things so i changed it
       rgb = [];
       rgb = hex2RGB(color);
       rgb['red'] += 10;
       rgb['green'] += 10; //by adding 10 to rgb, i am making the color lighter by 10 points;
       rgb['blue'] += 10;
       rgbHex = RGB2Hex(rgb['red'],rgb['green'],rgb['blue']);

        document.getElementById('messageDisplay').style.backgroundColor = "#" + rgbHex;
        document.getElementById('messageDisplayValue').style.backgroundColor = "#" + color;
       }



 

zero-perfoliate