View Single Post
Old 26-06-2007, 19:14   #5 (permalink)
Cborrow
I like code.
 
Join Date: Dec 2004
Location: Chesapeake, VA
Posts: 192
Send a message via AIM to Cborrow
For when you need to convert colors from/to rbg/hex

PHP Code:
function FromHex($color) {
    
$color ereg_replace("#"""$color);

    if(
strlen($color) == 3) {
        
$color  $color $color;
    }

    
$red hexdec(substr($color02));
    
$green hexdec(substr($color22));
    
$blue hexdec(substr($color42));

    return array(
$red$green$blue);
}
        
function 
FromRGB($color) {
    
$red $color['red'] || $color[0];
    
$blue $color['blue'] || $color[1];
    
$green $color['green'] || $color[2];
    
    
$red dechex($red);
    
$green dechex($green);
    
$blue dechex($blue);
    
    return 
"#" $red $green $blue;

  Reply With Quote