Beispiel #1
0
 /**
  * Creates a Zend_Pdf_Color object from the HTML representation.
  *
  * @param string $color May either be a hexidecimal number of the form
  *    #rrggbb or one of the 140 well-known names (black, white, blue, etc.)
  * @return Zend_Pdf_Color
  */
 public static function color($color)
 {
     $pattern = '/^#([A-Fa-f0-9]{2})([A-Fa-f0-9]{2})([A-Fa-f0-9]{2})$/';
     if (preg_match($pattern, $color, $matches)) {
         $r = round(hexdec($matches[1]) / 255, 3);
         $g = round(hexdec($matches[2]) / 255, 3);
         $b = round(hexdec($matches[3]) / 255, 3);
         if ($r == $g && $g == $b) {
             return new Zend_Pdf_Color_GrayScale($r);
         } else {
             return new Zend_Pdf_Color_RGB($r, $g, $b);
         }
     } else {
         return Zend_Pdf_Color_HTML::namedColor($color);
     }
 }