Created
April 24, 2023 18:30
-
-
Save dartiss/565ad26a8ac1b0b34a43fb4f8ce21fb4 to your computer and use it in GitHub Desktop.
Hex to color name compression
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$tocolor = array( | |
'#000080' => 'Navy', | |
'#008000' => 'Green', | |
'#008080' => 'Teal', | |
'#00FF00' => 'Lime', | |
'#4B0082' => 'Indigo', | |
'#800000' => 'Maroon', | |
'#800080' => 'Purple', | |
'#808000' => 'Olive', | |
'#808080' => 'Gray', | |
'#A0522D' => 'Sienna', | |
'#A52A2A' => 'Brown', | |
'#C0C0C0' => 'Silver', | |
'#CD853F' => 'Peru', | |
'#D2B48C' => 'Tan', | |
'#DA70D6' => 'Orchid', | |
'#DDA0DD' => 'Plum', | |
'#EE82EE' => 'Violet', | |
'#F0E68C' => 'Khaki', | |
'#F00' => 'Red', | |
'#F0FFFF' => 'Azure', | |
'#F5DEB3' => 'Wheat', | |
'#F5F5DC' => 'Beige', | |
'#FA8072' => 'Salmon', | |
'#FAF0E6' => 'Linen', | |
'#FF6347' => 'Tomato', | |
'#FF7F50' => 'Coral', | |
'#FFA500' => 'Orange', | |
'#FFC0CB' => 'Pink', | |
'#FFD700' => 'Gold', | |
'#FFE4C4' => 'Bisque', | |
'#FFFAFA' => 'Snow', | |
'#FFFFF0' => 'Ivory', | |
'#808080' => 'Grey', | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This array can be used to replace hex colour values with their corresponding colour name, where the latter is shorter. In the case of the hex, I've assumed this has already been reduced to its minimum size.