getHexColor() public static method

Returns the hexadecimal representation of an HTML color name.
public static getHexColor ( string $colorname ) : string
$colorname string A color name.
return string The hex representation of the color.
Example #1
0
File: Svg.php Project: horde/horde
 /**
  * Draws an arc.
  *
  * @param integer $x      The x coordinate of the centre.
  * @param integer $y      The y coordinate of the centre.
  * @param integer $r      The radius of the arc.
  * @param integer $start  The start angle of the arc.
  * @param integer $end    The end angle of the arc.
  * @param string $color   The line color of the arc.
  * @param string $fill    The fill color of the arc (defaults to none).
  */
 public function arc($x, $y, $r, $start, $end, $color = 'black', $fill = null)
 {
     if (!empty($fill)) {
         $style = 'fill:' . Horde_Image::getHexColor($fill) . '; ';
     } else {
         $style = 'fill:none;';
     }
     $style .= 'stroke:' . Horde_Image::getHexColor($color) . '; stroke-width:1';
     $mid = round(($start + $end) / 2);
     // Calculate the path entry.
     $path = '';
     // If filled, draw the outline.
     if (!empty($fill)) {
         // Start at the center of the ellipse the arc is on.
         $path .= "M {$x},{$y} ";
         // Draw out to ellipse edge.
         list($arcX, $arcY) = Horde_Image::circlePoint($start, $r * 2);
         $path .= 'L ' . round($x + $arcX) . ',' . round($y + $arcY) . ' ';
     }
     // Draw arcs.
     list($arcX, $arcY) = Horde_Image::circlePoint($mid, $r * 2);
     $path .= "A {$r},{$r} 0 0 1 " . round($x + $arcX) . ',' . round($y + $arcY) . ' ';
     list($arcX, $arcY) = Horde_Image::circlePoint($end, $r * 2);
     $path .= "A {$r},{$r} 0 0 1 " . round($x + $arcX) . ',' . round($y + $arcY) . ' ';
     // If filled, close the outline.
     if (!empty($fill)) {
         $path .= 'Z';
     }
     $path = trim($path);
     $this->_svg->addChild(new XML_SVG_Path(array('d' => $path, 'style' => $style)));
 }