<?php
/*************************************************
openWolf - an HTML accessibility guidelines validator
Author: Geoff Munn (hide@address.com)
Version: 0.9.9
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
You may contact the author of openWolf by e-mail at: hide@address.com
The latest version of openWolf can be obtained from:
http://openwolf.sourceforge.net/
*************************************************/
class Colours {
var $shades=Array();
var $names=Array();
var $images=Array();
function Colours(){
$this->shades['000000']['shade']='';
$this->shades['000000']['colour']='black';
$this->shades['000033']['shade']='very dark';
$this->shades['000033']['colour']='blue';
$this->shades['000066']['shade']='dark';
$this->shades['000066']['colour']='blue';
$this->shades['000099']['shade']='dark';
$this->shades['000099']['colour']='blue';
$this->shades['0000CC']['shade']='';
$this->shades['0000CC']['colour']='blue';
$this->shades['0000FF']['shade']='';
$this->shades['0000FF']['colour']='blue';
$this->shades['003300']['shade']='very dark';
$this->shades['003300']['colour']='green';
$this->shades['003333']['shade']='very dark';
$this->shades['003333']['colour']='aqua';
$this->shades['003366']['shade']='very dark';
$this->shades['003366']['colour']='blue';
$this->shades['003399']['shade']='dark';
$this->shades['003399']['colour']='blue';
$this->shades['0033CC']['shade']='';
$this->shades['0033CC']['colour']='blue';
$this->shades['0033FF']['shade']='';
$this->shades['0033FF']['colour']='blue';
$this->shades['006600']['shade']='dark';
$this->shades['006600']['colour']='green';
$this->shades['006633']['shade']='dark';
$this->shades['006633']['colour']='green';
$this->shades['006666']['shade']='dark';
$this->shades['006666']['colour']='aqua';
$this->shades['006699']['shade']='dark';
$this->shades['006699']['colour']='blue';
$this->shades['0066CC']['shade']='';
$this->shades['0066CC']['colour']='blue';
$this->shades['0066FF']['shade']='';
$this->shades['0066FF']['colour']='blue';
$this->shades['009900']['shade']='dark';
$this->shades['009900']['colour']='green';
$this->shades['009933']['shade']='dark';
$this->shades['009933']['colour']='green';
$this->shades['009966']['shade']='dark';
$this->shades['009966']['colour']='green';
$this->shades['009999']['shade']='dark';
$this->shades['009999']['colour']='aqua';
$this->shades['0099CC']['shade']='';
$this->shades['0099CC']['colour']='blue';
$this->shades['0099FF']['shade']='';
$this->shades['0099FF']['colour']='blue';
$this->shades['00CC00']['shade']='';
$this->shades['00CC00']['colour']='green';
$this->shades['00CC33']['shade']='';
$this->shades['00CC33']['colour']='green';
$this->shades['00CC66']['shade']='';
$this->shades['00CC66']['colour']='green';
$this->shades['00CC99']['shade']='light';
$this->shades['00CC99']['colour']='green';
$this->shades['00CCCC']['shade']='dark';
$this->shades['00CCCC']['colour']='aqua';
$this->shades['00CCFF']['shade']='light';
$this->shades['00CCFF']['colour']='blue';
$this->shades['00FF00']['shade']='';
$this->shades['00FF00']['colour']='green';
$this->shades['00FF33']['shade']='';
$this->shades['00FF33']['colour']='green';
$this->shades['00FF66']['shade']='light';
$this->shades['00FF66']['colour']='green';
$this->shades['00FF99']['shade']='light';
$this->shades['00FF99']['colour']='green';
$this->shades['00FFCC']['shade']='';
$this->shades['00FFCC']['colour']='aqua';
$this->shades['00FFFF']['shade']='';
$this->shades['00FFFF']['colour']='aqua';
$this->shades['330000']['shade']='very dark';
$this->shades['330000']['colour']='red';
$this->shades['330033']['shade']='very dark';
$this->shades['330033']['colour']='purple';
$this->shades['330066']['shade']='dark';
$this->shades['330066']['colour']='purple';
$this->shades['330099']['shade']='dark';
$this->shades['330099']['colour']='purple';
$this->shades['3300CC']['shade']='dark';
$this->shades['3300CC']['colour']='blue';
$this->shades['3300FF']['shade']='';
$this->shades['3300FF']['colour']='blue';
$this->shades['333300']['shade']='very dark';
$this->shades['333300']['colour']='yellow';
$this->shades['333333']['shade']='very dark';
$this->shades['333333']['colour']='grey';
$this->shades['333366']['shade']='dark';
$this->shades['333366']['colour']='blue';
$this->shades['333399']['shade']='';
$this->shades['333399']['colour']='blue';
$this->shades['3333CC']['shade']='';
$this->shades['3333CC']['colour']='blue';
$this->shades['3333FF']['shade']='';
$this->shades['3333FF']['colour']='blue';
$this->shades['336600']['shade']='dark';
$this->shades['336600']['colour']='green';
$this->shades['336633']['shade']='dark';
$this->shades['336633']['colour']='green';
$this->shades['336666']['shade']='dark';
$this->shades['336666']['colour']='aqua';
$this->shades['336699']['shade']='dark';
$this->shades['336699']['colour']='blue';
$this->shades['3366CC']['shade']='';
$this->shades['3366CC']['colour']='blue';
$this->shades['3366FF']['shade']='';
$this->shades['3366FF']['colour']='blue';
$this->shades['339900']['shade']='dark';
$this->shades['339900']['colour']='green';
$this->shades['339933']['shade']='dark';
$this->shades['339933']['colour']='green';
$this->shades['339966']['shade']='dark';
$this->shades['339966']['colour']='green';
$this->shades['339999']['shade']='dark';
$this->shades['339999']['colour']='aqua';
$this->shades['3399CC']['shade']='';
$this->shades['3399CC']['colour']='blue';
$this->shades['3399FF']['shade']='';
$this->shades['3399FF']['colour']='blue';
$this->shades['33CC00']['shade']='';
$this->shades['33CC00']['colour']='green';
$this->shades['33CC33']['shade']='';
$this->shades['33CC33']['colour']='green';
$this->shades['33CC66']['shade']='';
$this->shades['33CC66']['colour']='green';
$this->shades['33CC99']['shade']='light';
$this->shades['33CC99']['colour']='green';
$this->shades['33CCCC']['shade']='';
$this->shades['33CCCC']['colour']='aqua';
$this->shades['33CCFF']['shade']='light';
$this->shades['33CCFF']['colour']='blue';
$this->shades['33FF00']['shade']='';
$this->shades['33FF00']['colour']='green';
$this->shades['33FF33']['shade']='';
$this->shades['33FF33']['colour']='green';
$this->shades['33FF66']['shade']='';
$this->shades['33FF66']['colour']='green';
$this->shades['33FF99']['shade']='light';
$this->shades['33FF99']['colour']='green';
$this->shades['33FFCC']['shade']='light';
$this->shades['33FFCC']['colour']='green';
$this->shades['33FFFF']['shade']='';
$this->shades['33FFFF']['colour']='aqua';
$this->shades['660000']['shade']='dark';
$this->shades['660000']['colour']='red';
$this->shades['660033']['shade']='dark';
$this->shades['660033']['colour']='red';
$this->shades['660066']['shade']='dark';
$this->shades['660066']['colour']='purple';
$this->shades['660099']['shade']='dark';
$this->shades['660099']['colour']='purple';
$this->shades['6600CC']['shade']='';
$this->shades['6600CC']['colour']='purple';
$this->shades['6600FF']['shade']='';
$this->shades['6600FF']['colour']='blue';
$this->shades['663300']['shade']='very dark';
$this->shades['663300']['colour']='orange';
$this->shades['663333']['shade']='dark';
$this->shades['663333']['colour']='red';
$this->shades['663366']['shade']='dark';
$this->shades['663366']['colour']='purple';
$this->shades['663399']['shade']='';
$this->shades['663399']['colour']='purple';
$this->shades['6633CC']['shade']='dark';
$this->shades['6633CC']['colour']='blue'; //maybe not?
$this->shades['6633FF']['shade']='';
$this->shades['6633FF']['colour']='blue';
$this->shades['666600']['shade']='dark';
$this->shades['666600']['colour']='yellow';
$this->shades['666633']['shade']='dark';
$this->shades['666633']['colour']='yellow';
$this->shades['666666']['shade']='dark';
$this->shades['666666']['colour']='grey';
$this->shades['666699']['shade']='dark';
$this->shades['666699']['colour']='blue';
$this->shades['6666CC']['shade']='light';
$this->shades['6666CC']['colour']='blue';
$this->shades['6666FF']['shade']='light';
$this->shades['6666FF']['colour']='blue';
$this->shades['669900']['shade']='dark';
$this->shades['669900']['colour']='green';
$this->shades['669933']['shade']='dark';
$this->shades['669933']['colour']='green';
$this->shades['669966']['shade']='dark';
$this->shades['669966']['colour']='green';
$this->shades['669999']['shade']='dark';
$this->shades['669999']['colour']='aqua';
$this->shades['6699CC']['shade']='';
$this->shades['6699CC']['colour']='blue';
$this->shades['6699FF']['shade']='';
$this->shades['6699FF']['colour']='blue';
$this->shades['66CC00']['shade']='';
$this->shades['66CC00']['colour']='green';
$this->shades['66CC33']['shade']='';
$this->shades['66CC33']['colour']='green';
$this->shades['66CC66']['shade']='light';
$this->shades['66CC66']['colour']='green';
$this->shades['66CC99']['shade']='light';
$this->shades['66CC99']['colour']='green';
$this->shades['66CCCC']['shade']='light';
$this->shades['66CCCC']['colour']='blue';
$this->shades['66CCFF']['shade']='light';
$this->shades['66CCFF']['colour']='blue';
$this->shades['66FF00']['shade']='';
$this->shades['66FF00']['colour']='green';
$this->shades['66FF33']['shade']='';
$this->shades['66FF33']['colour']='green';
$this->shades['66FF66']['shade']='light';
$this->shades['66FF66']['colour']='green';
$this->shades['66FF99']['shade']='light';
$this->shades['66FF99']['colour']='green';
$this->shades['66FFCC']['shade']='light';
$this->shades['66FFCC']['colour']='green';
$this->shades['66FFFF']['shade']='light';
$this->shades['66FFFF']['colour']='aqua';
$this->shades['990000']['shade']='dark';
$this->shades['990000']['colour']='green';
$this->shades['990033']['shade']='dark';
$this->shades['990033']['colour']='red';
$this->shades['990066']['shade']='dark';
$this->shades['990066']['colour']='pink';
$this->shades['990099']['shade']='dark';
$this->shades['990099']['colour']='pink';
$this->shades['9900CC']['shade']='';
$this->shades['9900CC']['colour']='purple';
$this->shades['9900FF']['shade']='';
$this->shades['9900FF']['colour']='purple';
$this->shades['993300']['shade']='dark';
$this->shades['993300']['colour']='orange';
$this->shades['993333']['shade']='dark';
$this->shades['993333']['colour']='orange';
$this->shades['993366']['shade']='dark';
$this->shades['993366']['colour']='pink';
$this->shades['993399']['shade']='dark';
$this->shades['993399']['colour']='purple';
$this->shades['9933CC']['shade']='';
$this->shades['9933CC']['colour']='purple';
$this->shades['9933FF']['shade']='';
$this->shades['9933FF']['colour']='purple';
$this->shades['996600']['shade']='dark';
$this->shades['996600']['colour']='orange';
$this->shades['996633']['shade']='dark';
$this->shades['996633']['colour']='orange';
$this->shades['996666']['shade']='dark';
$this->shades['996666']['colour']='red';
$this->shades['996699']['shade']='dark';
$this->shades['996699']['colour']='purple';
$this->shades['9966CC']['shade']='';
$this->shades['9966CC']['colour']='purple';
$this->shades['9966FF']['shade']='';
$this->shades['9966FF']['colour']='purple';
$this->shades['999900']['shade']='dark';
$this->shades['999900']['colour']='yellow';
$this->shades['999933']['shade']='dark';
$this->shades['999933']['colour']='yellow';
$this->shades['999966']['shade']='dark';
$this->shades['999966']['colour']='yellow';
$this->shades['999999']['shade']='';
$this->shades['999999']['colour']='grey';
$this->shades['9999CC']['shade']='light';
$this->shades['9999CC']['colour']='blue';
$this->shades['9999FF']['shade']='light';
$this->shades['9999FF']['colour']='blue';
$this->shades['99CC00']['shade']='';
$this->shades['99CC00']['colour']='green';
$this->shades['99CC33']['shade']='';
$this->shades['99CC33']['colour']='green';
$this->shades['99CC66']['shade']='light';
$this->shades['99CC66']['colour']='green';
$this->shades['99CC99']['shade']='light';
$this->shades['99CC99']['colour']='green';
$this->shades['99CCCC']['shade']='light';
$this->shades['99CCCC']['colour']='blue';
$this->shades['99CCFF']['shade']='light';
$this->shades['99CCFF']['colour']='blue';
$this->shades['99FF00']['shade']='light';
$this->shades['99FF00']['colour']='green';
$this->shades['99FF33']['shade']='light';
$this->shades['99FF33']['colour']='green';
$this->shades['99FF66']['shade']='light';
$this->shades['99FF66']['colour']='green';
$this->shades['99FF99']['shade']='light';
$this->shades['99FF99']['colour']='green';
$this->shades['99FFCC']['shade']='light';
$this->shades['99FFCC']['colour']='green';
$this->shades['99FFFF']['shade']='light';
$this->shades['99FFFF']['colour']='blue';
$this->shades['CC0000']['shade']='';
$this->shades['CC0000']['colour']='red';
$this->shades['CC0033']['shade']='';
$this->shades['CC0033']['colour']='red';
$this->shades['CC0066']['shade']='';
$this->shades['CC0066']['colour']='red';
$this->shades['CC0099']['shade']='';
$this->shades['CC0099']['colour']='pink';
$this->shades['CC00CC']['shade']='';
$this->shades['CC00CC']['colour']='pink';
$this->shades['CC00FF']['shade']='';
$this->shades['CC00FF']['colour']='pink';
$this->shades['CC3300']['shade']='dark';
$this->shades['CC3300']['colour']='orange';
$this->shades['CC3333']['shade']='dark';
$this->shades['CC3333']['colour']='orange';
$this->shades['CC3366']['shade']='dark';
$this->shades['CC3366']['colour']='pink';
$this->shades['CC3399']['shade']='';
$this->shades['CC3399']['colour']='pink';
$this->shades['CC33CC']['shade']='';
$this->shades['CC33CC']['colour']='pink';
$this->shades['CC33FF']['shade']='';
$this->shades['CC33FF']['colour']='pink';
$this->shades['CC6600']['shade']='';
$this->shades['CC6600']['colour']='orange';
$this->shades['CC6633']['shade']='';
$this->shades['CC6633']['colour']='orange';
$this->shades['CC6666']['shade']='light';
$this->shades['CC6666']['colour']='orange';
$this->shades['CC6699']['shade']='light';
$this->shades['CC6699']['colour']='pink';
$this->shades['CC66CC']['shade']='light';
$this->shades['CC66CC']['colour']='pink';
$this->shades['CC66FF']['shade']='';
$this->shades['CC66FF']['colour']='pink';
$this->shades['CC9900']['shade']='';
$this->shades['CC9900']['colour']='orange';
$this->shades['CC9933']['shade']='';
$this->shades['CC9933']['colour']='orange';
$this->shades['CC9966']['shade']='light';
$this->shades['CC9966']['colour']='orange';
$this->shades['CC9999']['shade']='light';
$this->shades['CC9999']['colour']='red';
$this->shades['CC99CC']['shade']='light';
$this->shades['CC99CC']['colour']='pink';
$this->shades['CC99FF']['shade']='light';
$this->shades['CC99FF']['colour']='pink';
$this->shades['CCCC00']['shade']='dark';
$this->shades['CCCC00']['colour']='yellow';
$this->shades['CCCC33']['shade']='dark';
$this->shades['CCCC33']['colour']='yellow';
$this->shades['CCCC66']['shade']='light';
$this->shades['CCCC66']['colour']='yellow';
$this->shades['CCCC99']['shade']='light';
$this->shades['CCCC99']['colour']='yellow';
$this->shades['CCCCCC']['shade']='light';
$this->shades['CCCCCC']['colour']='grey';
$this->shades['CCCCFF']['shade']='light';
$this->shades['CCCCFF']['colour']='blue';
$this->shades['CCFF00']['shade']='light';
$this->shades['CCFF00']['colour']='green';
$this->shades['CCFF33']['shade']='light';
$this->shades['CCFF33']['colour']='green';
$this->shades['CCFF66']['shade']='light';
$this->shades['CCFF66']['colour']='green';
$this->shades['CCFF99']['shade']='light';
$this->shades['CCFF99']['colour']='green';
$this->shades['CCFFCC']['shade']='very light';
$this->shades['CCFFCC']['colour']='green';
$this->shades['CCFFFF']['shade']='very light';
$this->shades['CCFFFF']['colour']='blue';
$this->shades['FF0000']['shade']='';
$this->shades['FF0000']['colour']='red';
$this->shades['FF0033']['shade']='';
$this->shades['FF0033']['colour']='red';
$this->shades['FF0066']['shade']='';
$this->shades['FF0066']['colour']='red';
$this->shades['FF0099']['shade']='';
$this->shades['FF0099']['colour']='pink';
$this->shades['FF00CC']['shade']='';
$this->shades['FF00CC']['colour']='pink';
$this->shades['FF00FF']['shade']='';
$this->shades['FF00FF']['colour']='pink';
$this->shades['FF3300']['shade']='';
$this->shades['FF3300']['colour']='red';
$this->shades['FF3333']['shade']='';
$this->shades['FF3333']['colour']='red';
$this->shades['FF3366']['shade']='';
$this->shades['FF3366']['colour']='pink';
$this->shades['FF3399']['shade']='';
$this->shades['FF3399']['colour']='pink';
$this->shades['FF33CC']['shade']='';
$this->shades['FF33CC']['colour']='pink';
$this->shades['FF33FF']['shade']='light';
$this->shades['FF33FF']['colour']='purple';
$this->shades['FF6600']['shade']='';
$this->shades['FF6600']['colour']='orange';
$this->shades['FF6633']['shade']='';
$this->shades['FF6633']['colour']='orange';
$this->shades['FF6666']['shade']='light';
$this->shades['FF6666']['colour']='orange';
$this->shades['FF6699']['shade']='light';
$this->shades['FF6699']['colour']='pink';
$this->shades['FF66CC']['shade']='light';
$this->shades['FF66CC']['colour']='pink';
$this->shades['FF66FF']['shade']='light';
$this->shades['FF66FF']['colour']='pink';
$this->shades['FF9900']['shade']='';
$this->shades['FF9900']['colour']='orange';
$this->shades['FF9933']['shade']='';
$this->shades['FF9933']['colour']='orange';
$this->shades['FF9966']['shade']='light';
$this->shades['FF9966']['colour']='orange';
$this->shades['FF9999']['shade']='light';
$this->shades['FF9999']['colour']='red';
$this->shades['FF99CC']['shade']='light';
$this->shades['FF99CC']['colour']='pink';
$this->shades['FF99FF']['shade']='light';
$this->shades['FF99FF']['colour']='purple';
$this->shades['FFCC00']['shade']='';
$this->shades['FFCC00']['colour']='yellow';
$this->shades['FFCC33']['shade']='';
$this->shades['FFCC33']['colour']='yellow';
$this->shades['FFCC66']['shade']='light';
$this->shades['FFCC66']['colour']='yellow';
$this->shades['FFCC99']['shade']='very light';
$this->shades['FFCC99']['colour']='yellow';
$this->shades['FFCCCC']['shade']='very light';
$this->shades['FFCCCC']['colour']='red';
$this->shades['FFCCFF']['shade']='very light';
$this->shades['FFCCFF']['colour']='pink';
$this->shades['FFFF00']['shade']='';
$this->shades['FFFF00']['colour']='yellow';
$this->shades['FFFF33']['shade']='';
$this->shades['FFFF33']['colour']='yellow';
$this->shades['FFFF66']['shade']='light';
$this->shades['FFFF66']['colour']='yellow';
$this->shades['FFFF99']['shade']='very light';
$this->shades['FFFF99']['colour']='yellow';
$this->shades['FFFFCC']['shade']='very light';
$this->shades['FFFFCC']['colour']='yellow';
$this->shades['FFFFFF']['shade']='';
$this->shades['FFFFFF']['colour']='white';
$this->names['black']='000000';
$this->names['white']='FFFFFF';
$this->names['red']='FF0000';
$this->names['yellow']='FFFF00';
$this->names['lime']='00FF00';
$this->names['aqua']='00FFFF';
$this->names['blue']='0000FF';
$this->names['fuchsia']='FF00FF';
$this->names['gray']='808080';
$this->names['silver']='C0C0C0';
$this->names['maroon']='800000';
$this->names['olive']='808000';
$this->names['green']='008000';
$this->names['teal']='008080';
$this->names['navy']='000080';
$this->names['purple']='800080';
$this->names['aliceblue']='F0F8FF';
$this->names['antiquewhite']='FAEBD7';
//Aqua
//#00FFFF
$this->names['aquamarine']='7FFFD4';
$this->names['azure']='F0FFFF';
$this->names['beige']='F5F5DC';
$this->names['bisque']='FFE4C4';
//Black
//#000000
$this->names['blanchedalmond']='FFEBCD';
//Blue
//#0000FF
$this->names['blueviolet']='8A2BE2';
$this->names['brown']='A52A2A';
$this->names['burlywood']='DEB887';
$this->names['cadetblue']='5F9EA0';
$this->names['chartreuse']='7FFF00';
$this->names['chocolate']='D2691E';
$this->names['coral']='FF7F50';
$this->names['cornflowerblue']='6495ED';
$this->names['cornsilk']='FFF8DC';
$this->names['crimson']='DC143C';
$this->names['cyan']='00FFFF';
$this->names['darkblue']='00008B';
$this->names['darkcyan']='008B8B';
$this->names['darkgoldenrod']='B8860B';
$this->names['darkgray']='A9A9A9';
$this->names['darkgreen']='006400';
$this->names['darkkhaki']='BDB76B';
$this->names['darkmagenta']='8B008B';
$this->names['darkolivegreen']='556B2F';
$this->names['darkorange']='FF8C00';
$this->names['darkorchid']='9932CC';
$this->names['darkred']='8B0000';
$this->names['darksalmon']='E9967A';
$this->names['darkseagreen']='8FBC8F';
$this->names['darkslateblue']='483D8B';
$this->names['darkslategray']='2F4F4F';
$this->names['darkturquoise']='00CED1';
$this->names['darkviolet']='9400D3';
$this->names['deeppink']='FF1493';
$this->names['deepskyblue']='00BFFF';
$this->names['dimgray']='696969';
$this->names['dodgerblue']='1E90FF';
$this->names['firebrick']='B22222';
$this->names['floralwhite']='FFFAF0';
$this->names['forestgreen']='228B22';
//Fuchsia
//#FF00FF
$this->names['gainsboro']='DCDCDC';
$this->names['ghostwhite']='F8F8FF';
$this->names['gold']='FFD700';
$this->names['goldenrod']='DAA520';
//Gray
//#808080
//Green
//#008000
$this->names['greenyellow']='ADFF2F';
$this->names['honeydew']='F0FFF0';
$this->names['hotpink']='FF69B4';
$this->names['indianred']='CD5C5C';
$this->names['indigo']='4B0082';
$this->names['ivory']='FFFFF0';
$this->names['khaki']='F0E68C';
$this->names['lavender']='E6E6FA';
$this->names['lavenderblush']='FFF0F5';
$this->names['lawngreen']='7CFC00';
$this->names['lemonchiffon']='FFFACD';
$this->names['lightblue']='ADD8E6';
$this->names['lightcoral']='F08080';
$this->names['lightcyan']='E0FFFF';
$this->names['lightgoldenrodyellow']='FAFAD2';
$this->names['lightgreen']='90EE90';
$this->names['lightgrey']='D3D3D3';
$this->names['lightpink']='FFB6C1';
$this->names['lightsalmon']='FFA07A';
$this->names['lightseagreen']='20B2AA';
$this->names['lightskyblue']='87CEFA';
$this->names['lightslategray']='778899';
$this->names['lightsteelblue']='B0C4DE';
$this->names['lightyellow']='FFFFE0';
//Lime
//#00FF00
$this->names['limegreen']='32CD32';
$this->names['linen']='FAF0E6';
$this->names['magenta']='FF00FF';
//Maroon
//#800000
$this->names['mediumaquamarine']='66CDAA';
$this->names['mediumblue']='0000CD';
$this->names['mediumorchid']='BA55D3';
$this->names['mediumpurple']='9370DB';
$this->names['mediumseagreen']='3CB371';
$this->names['mediumslateblue']='7B68EE';
$this->names['mediumspringgreen']='00FA9A';
$this->names['mediumturquoise']='48D1CC';
$this->names['mediumvioletred']='C71585';
$this->names['midnightblue']='191970';
$this->names['mintcream']='F5FFFA';
$this->names['mistyrose']='FFE4E1';
$this->names['moccasin']='FFE4B5';
$this->names['navajowhite']='FFDEAD';
//Navy
//#000080
$this->names['oldlace']='FDF5E6';
//Olive
//#808000
$this->names['olivedrab']='6B8E23';
$this->names['orange']='FFA500';
$this->names['orangered']='FF4500';
$this->names['orchid']='DA70D6';
$this->names['palegoldenrod']='EEE8AA';
$this->names['palegreen']='98FB98';
$this->names['paleturquoise']='AFEEEE';
$this->names['palevioletred']='DB7093';
$this->names['papayawhip']='FFEFD5';
$this->names['peachpuff']='FFDAB9';
$this->names['peru']='CD853F';
$this->names['pink']='FFC0CB';
$this->names['plum']='DDA0DD';
$this->names['powderblue']='B0E0E6';
//Purple
//#800080
//Red
//#FF0000
$this->names['rosybrown']='BC8F8F';
$this->names['royalblue']='4169E1';
$this->names['saddlebrown']='8B4513';
$this->names['salmon']='FA8072';
$this->names['sandybrown']='F4A460';
$this->names['seagreen']='2E8B57';
$this->names['seashell']='FFF5EE';
$this->names['sienna']='A0522D';
//Silver
//#C0C0C0
$this->names['skyblue']='87CEEB';
$this->names['slateblue']='6A5ACD';
$this->names['slategray']='708090';
$this->names['snow']='FFFAFA';
$this->names['springgreen']='00FF7F';
$this->names['steelblue']='4682B4';
$this->names['tan']='D2B48C';
//Teal
//#008080
$this->names['thistle']='D8BFD8';
$this->names['tomato']='FF6347';
$this->names['turquoise']='40E0D0';
$this->names['violet']='EE82EE';
$this->names['wheat']='F5DEB3';
//White
//#FFFFFF
$this->names['whitesmoke']='F5F5F5';
//Yellow
//#FFFF00
$this->names['yellowgreen']='9ACD32';
}
function get_colour_by_hex($in, $convert){
if($convert){
// put values into an easy-to-use array
$in=strtoupper($in);
$in=str_replace('#','', $in);
$in=str_replace('&h','', strtolower($in));
//$length=strlen($in);
//if($length==1 || $length==3 || $length==5){
// $in=$in . substr($in,-1);
//}
$in=substr($in . '000000',0,6);
$vals['r'] = hexdec( substr($in, 0, 2) );
$vals['g'] = hexdec( substr($in, 2, 2) );
$vals['b'] = hexdec( substr($in, 4, 2) );
// loop through
$out='';
foreach( $vals as $val ){
// convert value
$val = ( round($val/51) * 51 );
// convert to HEX
$out .= str_pad(dechex($val), 2, '0', STR_PAD_LEFT);
}
return strtoupper($out);
} else {
return strtoupper($in);
}
}
function get_colour_by_rgb($in, $convert){
$in=str_replace('rgb(', '', strtolower($in));
$in=str_replace(')', '', $in);
$temp=explode(',', $in);
$vals['r']=trim($temp[0]);
$vals['g']=trim($temp[1]);
$vals['b']=trim($temp[2]);
// loop through
$out='';
foreach( $vals as $val ){
// convert value
if($convert){
$val = ( round($val/51) * 51 );
}
// convert to HEX
$out .= str_pad(dechex($val), 2, '0', STR_PAD_LEFT);
}
return strtoupper($out);
}
function get_colour_by_name($colour, $convert=true){
//does this colour exist?
$colour=strtolower($colour);
if(isset($this->names[$colour])){
if($convert){
$hex=$this->get_colour_by_hex($this->names[$colour], $convert);
} else {
$hex=$this->names[$colour];
}
} else {
$hex='';
}
return strtoupper($hex);
}
function get_colour_details($colour, $convert=true){
//First, is this colour and RGB, hex, number or name?
//if it starts with a # it is a hex
//if it starts with RGB it is an rgb
//if it is numeric it is a number
//after all this, it is a name
//is this a hex value?
//echo '<pre>';
//print_r($colour);
//echo '</pre>';
$first_char=substr($colour,0,1);
switch(TRUE){
case ($first_char=='#'):
//echo 'getting hex<br>';
$safe=$this->get_colour_by_hex($colour, $convert);
break;
case (substr(strtolower($colour),0,3)=='rgb'):
//This is an RGB colour:
$safe=$this->get_colour_by_rgb($colour, $convert);
break;
case (is_numeric($colour)):
//TODO: does this correctly return unconverted numeric colours?
$safe=$this->get_colour_by_hex(dechex($colour), $convert);
break;
default:
//this is a colour name:
//echo 'getting name<br>';
$safe=$this->get_colour_by_name($colour, $convert);
//This might actually be a colour hex value minus the #, it happens sometimes :)
if($safe=='')
$safe=$this->get_colour_by_hex($colour, $convert);
break;
}
$safe=trim($safe, '#');
//echo 'the colour ' . $colour . ' is ' . $safe . '<BR>';
if($convert){
if($safe!='')
return $this->shades[$safe];
else
return '';
} else {
return $safe;
}
}
function is_websafe($colour){
//If the colour is in the form 'fff' then this gets converted to ffffff
//if(strlen($colour)==4){
// $colour=$colour.$colour;
//}
//if(strlen($colour!=6)){
// $colour=substr($colour.'000000',0,6);
//}
//echo 'is ' . $colour . ' websafe? ';
$websafe=true;
if($colour!=''){
$colour=$this->get_colour_details($colour, false);
$colour=trim($colour, '#');
$bits=str_split(strtoupper($colour),2);
//websafe colours must be a combination of 00, 33, 66, 99, CC and FF
foreach($bits as $this_bit){
if($this_bit!='00' && $this_bit!='33' && $this_bit!='66' && $this_bit!='99' && $this_bit!='CC' && $this_bit!='FF'){
$websafe=false;
break;
}
}
}
return $websafe;
}
function rgb2hex($rgb){
//if(!is_array($rgb) || count($rgb) >= 3){
// return '';
//}
for($i=0;$i<3;$i++){
if(strlen($hex[$i] = dechex($rgb[$i])) == 1){
$hex[$i] = '0'.$hex[$i];
}
}
return $hex;
}
function is_image_websafe($src){
if(!isset($this->images[$src])){
$headers=fetch_file($src);
$is_websafe=true;
if(is_response_good($headers)){
$type=trim($headers['content-type']);
if($type=='image/jpeg'){
$image = imagecreatefromjpeg($src);
imagetruecolortopalette($image, false, 256);
}
if($type=='image/png'){
$image = imagecreatefrompng($src);
imagetruecolortopalette($image, false, 256);
}
if($type=='image/gif'){
$image=imagecreatefromgif($src);
}
//count the number of colours:
$count=imagecolorstotal($image);
if($count>216){
$is_websafe=false;
} else {
//go through each palette entry:
for($i=0;$i<$count;$i++){
$colour=imagecolorsforindex($image,$i);
$rgb[0]=$colour['red'];
$rgb[1]=$colour['green'];
$rgb[2]=$colour['blue'];
$hex=$this->rgb2hex($rgb);
$hex='#' . implode($hex);
//echo 'the colour is ' . $hex . '<br>';
if($this->is_websafe($hex)===false){
//echo 'this colour . ' . $hex . ' is not websafe<br>';
$is_websafe=false;
break;
}
}
}
}
$this->images[$src]=$is_websafe;
} else {
$is_websafe=$this->images[$src];
}
//echo 'this image (' . $src . ') is websafe? ' . $is_websafe . '<br>';
return $is_websafe;
}
function fix_value($hex){
//This assumes that the hex value DOES NOT include the # character
switch(strlen($hex)){
case 1:
$hex=$hex.$hex.$hex.$hex.$hex.$hex;
break;
case 2:
$hex=$hex.'0000';
break;
case 3:
$first=substr($hex,0,1);
$second=substr($hex, 1,1);
$third=substr($hex, 2,1);
$hex=$first . $first . $second . $second . $third . $third;
default:
$hex=$hex;
}
return $hex;
}
function does_contrast($background_colour, $foreground_colour){
/*((Red value X 299) + (Green value X 587) + (Blue value X 114)) / 1000*/
/*(maximum (Red value 1, Red value 2) - minimum (Red value 1, Red value 2)) + (maximum (Green value 1, Green value 2) - minimum (Green value 1, Green value 2)) + (maximum (Blue value 1, Blue value 2) - minimum (Blue value 1, Blue value 2))*/
$background_colour=$this->fix_value(trim($background_colour, '#'));
$foreground_colour=$this->fix_value(trim($foreground_colour, '#'));
$bcolour=Array();
$fcolour=Array();
// put values into an easy-to-use array
$bcolour['r'] = hexdec( substr($background_colour, 0, 2) );
$bcolour['g'] = hexdec( substr($background_colour, 2, 2) );
$bcolour['b'] = hexdec( substr($background_colour, 4, 2) );
$fcolour['r'] = hexdec( substr($foreground_colour, 0, 2) );
$fcolour['g'] = hexdec( substr($foreground_colour, 2, 2) );
$fcolour['b'] = hexdec( substr($foreground_colour, 4, 2) );
$back_brightness=(($bcolour['r']*299) + ($bcolour['g']*587) + ($bcolour['b']*114))/1000;
$fore_brightness=(($fcolour['r']*299) + ($fcolour['g']*587) + ($fcolour['b']*114))/1000;
$brightness_bad=false;
if(abs($fore_brightness-$back_brightness)<125){
$brightness_bad=true;
}
/*
$max_r=max(array($bcolor_r, $fcolor_r));
$min_r=min(array($bcolor_r, $fcolor_r));
$max_g=max(array($bcolor_g, $fcolor_g));
$min_g=min(array($bcolor_g, $fcolor_g));
$max_b=max(array($bcolor_b, $fcolor_b));
$min_b=min(array($bcolor_b, $fcolor_b));
*/
$max_r=max($bcolour['r'], $fcolour['r']);
$min_r=min($bcolour['r'], $fcolour['r']);
$max_g=max($bcolour['g'], $fcolour['g']);
$min_g=min($bcolour['g'], $fcolour['g']);
$max_b=max($bcolour['b'], $fcolour['b']);
$min_b=min($bcolour['b'], $fcolour['b']);
$contrast_bad=false;
if(($max_r-$min_r)+($max_g-$min_g)+($max_b-$min_b)<500){
$contrast_bad=true;
}
if($contrast_bad && $brightness_bad){
return false;
}else {
return true;
}
}
function hex2rgb($hex, $asString = true) {
// strip off any leading #
if (0 === strpos($hex, '#')) {
$hex = substr($hex, 1);
} else if (0 === strpos($hex, '&H')) {
$hex = substr($hex, 2);
}
// break into hex 3-tuple
$cutpoint = ceil(strlen($hex) / 2)-1;
$rgb = explode(':', wordwrap($hex, $cutpoint, ':', $cutpoint), 3);
// convert each tuple to decimal
$rgb[0] = (isset($rgb[0]) ? hexdec($rgb[0]) : 0);
$rgb[1] = (isset($rgb[1]) ? hexdec($rgb[1]) : 0);
$rgb[2] = (isset($rgb[2]) ? hexdec($rgb[2]) : 0);
return ($asString ? "{$rgb[0]} {$rgb[1]} {$rgb[2]}" : $rgb);
}
}
?>