09-04-2008, 10:47 PM
|
#2 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
php Code:
function toHexFromRGB ($iRed, $iGreen, $iBlue){ return sprintf('%06X', $iRed . $iGreen . $iBlue); }function toRGBFromHex ($szHex){ $aRGB = array(); for ($iIndex = 0; $iIndex < 3; $iIndex++ ) { switch ($iIndex) { case 0: $szKey = 'red'; break; case 1: $szKey = 'green'; break; case 2: $szKey = 'blue'; break; } $aRGB[ $szKey] = hexdec(substr($szHex, (2 * $iIndex), 2)); } return (object ) $aRGB; }$pRGB = toRGBFromHex ('00FFEE'); printf( "Red = %s<br />Green = %s<br />Blue = %s<br />Hex = %s", $pRGB-> red, $pRGB-> green, $pRGB-> blue, toHexFromRGB (255, 0, 0));
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|