[PHP] Convert a grayscale value to a #RRGGBB hex value

2002-06-24 Thread René Fournier

Anyone know how I might convert a grayscale value, from between 0 to 
100, to hex, such that 0 (black) would be returned as #00, and 100 
(white) as #FF? For example...

function grayscaletohex ($val) {
$hex = $val ... [ a simple operation ]
return $hex;
}

Thanks.

...Rene

---
René Fournier,
[EMAIL PROTECTED]

Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com

SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Convert a grayscale value to a #RRGGBB hex value

2002-06-24 Thread René Fournier

Anyone know how I might convert a grayscale value, from between 0 to 
100, to hex, such that 0 (black) would be returned as #00, and 100 
(white) as #FF? For example...

function grayscaletohex ($val) {
$hex = $val ... [ a simple operation ]
return $hex;
}

Thanks.

...Rene

---
René Fournier,
[EMAIL PROTECTED]

Toll-free +1.888.886.2754
Tel +1.403.291.3601
Fax +1.403.250.5228
www.smartslitters.com

SmartSlitters International
#33, 1339 - 40th Ave NE
Calgary AB  T2E 8N6
Canada


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Convert a grayscale value to a #RRGGBB hex value

2002-06-24 Thread Lazor, Ed

I have an idea on how to do this.  Could someone confirm whether this is a
good approach?

function grayscaletohex ($val)
{
$n = ($val * 255) / 100;// convert from range of 100 to
range of 255
$h = dechex($n);// convert decimal to hex
$results = $h.$h.$h;// create 6 digit browser color
string
return $results;
}



 -Original Message-
 From: René Fournier [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, June 23, 2002 12:52 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Convert a grayscale value to a #RRGGBB hex value
 
 
 Anyone know how I might convert a grayscale value, from between 0 to 
 100, to hex, such that 0 (black) would be returned as 
 #00, and 100 
 (white) as #FF? For example...
 
 function grayscaletohex ($val) {
   $hex = $val ... [ a simple operation ]
   return $hex;
   }
 
 Thanks.
 
 ...Rene
 
 ---
 René Fournier,
 [EMAIL PROTECTED]
 
 Toll-free +1.888.886.2754
 Tel +1.403.291.3601
 Fax +1.403.250.5228
 www.smartslitters.com
 
 SmartSlitters International
 #33, 1339 - 40th Ave NE
 Calgary AB  T2E 8N6
 Canada
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

This message is intended for the sole use of the individual and entity to
whom it is addressed, and may contain information that is privileged,
confidential and exempt from disclosure under applicable law.  If you are
not the intended addressee, nor authorized to receive for the intended
addressee, you are hereby notified that you may not use, copy, disclose or
distribute to anyone the message or any information contained in the
message.  If you have received this message in error, please immediately
advise the sender by reply email and delete the message.  Thank you very
much.   

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php