protected function parse_color($color) {
        if (strpos($color, '#') === 0) {
            // No conversion should be needed.
            return $color;
        }

        if ($color > 7 and $color < 53) {
            $numbers = array(
                8  => 'black',
                12 => 'blue',
                16 => 'brown',
                15 => 'cyan',
                23 => 'gray',
                17 => 'green',
                11 => 'lime',
                14 => 'magenta',
                18 => 'navy',
                53 => 'orange',
                33 => 'pink',
                20 => 'purple',
                10 => 'red',
                22 => 'silver',
                9  => 'white',
                13 => 'yellow',
            );
            if (isset($numbers[$color])) {
                $color = $numbers[$color];
            } else {
                $color = 'black';
            }
        }

        $colors = array(
            'aqua'    => '00FFFF',
            'black'   => '000000',
            'blue'    => '0000FF',
            'brown'   => 'A52A2A',
            'cyan'    => '00FFFF',
            'fuchsia' => 'FF00FF',
            'gray'    => '808080',
            'grey'    => '808080',
            'green'   => '00FF00',
            'lime'    => '00FF00',
            'magenta' => 'FF00FF',
            'maroon'  => '800000',
            'navy'    => '000080',
            'orange'  => 'FFA500',
            'olive'   => '808000',
            'pink'    => 'FAAFBE',
            'purple'  => '800080',
            'red'     => 'FF0000',
            'silver'  => 'C0C0C0',
            'teal'    => '008080',
            'white'   => 'FFFFFF',
            'yellow'  => 'FFFF00',
        );

        if (isset($colors[$color])) {
            return('#'.$colors[$color]);
        }

        return('#'.$colors['black']);
    }
protected function parse_color($color) {
        if (strpos($color, '#') === 0) {
            // No conversion should be needed.
            return $color;
        }

        if ($color > 7 and $color < 53) {
            $numbers = array(
                8  => 'black',
                12 => 'blue',
                16 => 'brown',
                15 => 'cyan',
                23 => 'gray',
                17 => 'green',
                11 => 'lime',
                14 => 'magenta',
                18 => 'navy',
                53 => 'orange',
                33 => 'pink',
                20 => 'purple',
                10 => 'red',
                22 => 'silver',
                9  => 'white',
                13 => 'yellow',
            );
            if (isset($numbers[$color])) {
                $color = $numbers[$color];
            } else {
                $color = 'black';
            }
        }

        $colors = array(
            'aqua'    => '00FFFF',
            'black'   => '000000',
            'blue'    => '0000FF',
            'brown'   => 'A52A2A',
            'cyan'    => '00FFFF',
            'fuchsia' => 'FF00FF',
            'gray'    => '808080',
            'grey'    => '808080',
            'green'   => '00FF00',
            'lime'    => '00FF00',
            'magenta' => 'FF00FF',
            'maroon'  => '800000',
            'navy'    => '000080',
            'orange'  => 'FFA500',
            'olive'   => '808000',
            'pink'    => 'FAAFBE',
            'purple'  => '800080',
            'red'     => 'FF0000',
            'silver'  => 'C0C0C0',
            'teal'    => '008080',
            'white'   => 'FFFFFF',
            'yellow'  => 'FFFF00',
        );

        if (isset($colors[$color])) {
            return('#'.$colors[$color]);
        }

        return('#'.$colors['black']);
    }
protected function parse_color ( $ color ) { if ( strpos ( $ color , '#' ) === 0 ) { // No conversion should be needed. return $ color ; } if ( $ color > 7 and $ color < 53 ) { $ numbers = array ( 8 => 'black' , 12 => 'blue' , 16 => 'brown' , 15 => 'cyan' , 23 => 'gray' , 17 => 'green' , 11 => 'lime' , 14 => 'magenta' , 18 => 'navy' , 53 => 'orange' , 33 => 'pink' , 20 => 'purple' , 10 => 'red' , 22 => 'silver' , 9 => 'white' , 13 => 'yellow' , ) ; if ( isset ( $ numbers [ $ color ] ) ) { $ color = $ numbers [ $ color ] ; } else { $ color = 'black' ; } } $ colors = array ( 'aqua' => '00FFFF' , 'black' => '000000' , 'blue' => '0000FF' , 'brown' => 'A52A2A' , 'cyan' => '00FFFF' , 'fuchsia' => 'FF00FF' , 'gray' => '808080' , 'grey' => '808080' , 'green' => '00FF00' , 'lime' => '00FF00' , 'magenta' => 'FF00FF' , 'maroon' => '800000' , 'navy' => '000080' , 'orange' => 'FFA500' , 'olive' => '808000' , 'pink' => 'FAAFBE' , 'purple' => '800080' , 'red' => 'FF0000' , 'silver' => 'C0C0C0' , 'teal' => '008080' , 'white' => 'FFFFFF' , 'yellow' => 'FFFF00' , ) ; if ( isset ( $ colors [ $ color ] ) ) { return ( '#' . $ colors [ $ color ] ) ; } return ( '#' . $ colors [ 'black' ] ) ; }
Standardise colour name.

@param mixed $color name of the color (i.e.: 'blue', 'red', etc..), or an integer (range is [8...63]).
@return string the RGB color value
Standardise colour name .