Pages: [1]   Go Down
Author Topic: RGB to Hex and Hex to RGB  (Read 1064 times)
hotnoob
PhpBar.isgreat.org
Hero Member
*****

Karma: +0/-0
Offline Offline

Posts: 113


WWW
« on: December 10, 2009, 09:56:49 AM »

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:
    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;
       }


Report to moderator   Logged

http://phpbar.isgreat.org
Feel free to check out my forums for more tutorials and help Cheesy

Pages: [1]   Go Up
Print
 
Jump to:  

Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC | Theme Kani By Fussilet

Page created in 0.033 seconds with 21 queries.