Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

1. ## HEX 2 Colo-u-r

If I have a hexidecimal color:

EG:
#FFFFFF
OR:
#ACED00

How do i get this to represent this in alphabetical characters

EG:
White
OR:
Light Green

Is there a simple mathemtical way to calculate the HEX and turn it into a string?

-Bash

• What you have is a string containing a color value in hexadecimal notation. The pair of hex digits stands for (in order) red, green and blue. The range of color value is from 0 (none) to 255 (full). You can transform the string value into hex numbers by using this function out of PEAR::Image_Color:

PHP Code:
``` function _splitColor ( \$color )     {         \$color = str_replace('#', '', \$color);         \$c[] = hexdec( substr( \$color, 0, 2 ) );         \$c[] = hexdec( substr( \$color, 2, 2 ) );         \$c[] = hexdec( substr( \$color, 4, 2 ) );         return \$c;     }  ```
The whole package can be found and browsed at http://cvs.php.net/co.php/pear/Image...lor.php?r=1.11 In this package there's also an array of color names and their corresponding hex values, although the keys are the color names. You'd need to sort this array first by a custom function, and then you could loop through it with a foreach loop and get the closest match for the tested color. Then the key of this match is the color name.

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•