/**
  * @param HtmlColor|string|null $color
  * @param float $opacity
  *
  * @return $this
  * @throws \Exception
  */
 public function setColor($color, $opacity = 1.0)
 {
     if (null === $color) {
         $this->color = null;
         $this->opacity = 0.0;
     } elseif ($color instanceof HtmlColor) {
         $this->color = $color;
         $this->opacity = (double) $opacity;
     } elseif (is_string($color)) {
         if (preg_match(HtmlColor::PATTERN_HEX, $color, $matches)) {
             $this->color = HtmlColor::byHex($color);
             $this->opacity = (double) $opacity;
         } elseif (preg_match(HtmlColor::PATTERN_RGB, $color, $matches)) {
             $this->color = HtmlColor::rgb((int) $matches[1], (int) $matches[2], (int) $matches[3]);
             $this->opacity = (double) $opacity;
         } elseif (preg_match(HtmlColor::PATTERN_RGBA, $color, $matches)) {
             $this->color = HtmlColor::rgb((int) $matches[1], (int) $matches[2], (int) $matches[3]);
             $this->opacity = (double) $matches[4];
         } else {
             $this->color = HtmlColor::byName($color);
             $this->opacity = (double) $opacity;
         }
     } else {
         throw new InvalidArgumentException('invalid color: ' . get_class($color));
     }
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * @param HtmlColor $color
  *
  * @return ZendColor
  */
 private function getZendColor(HtmlColor $color)
 {
     return ZendHtmlColor::color($color->__toString());
 }
Ejemplo n.º 3
0
    }
    return $path;
}
$graphic = new Graphic();
$graphic->setViewportCorners(-300, -300, 300, 300);
$graphic->getDefaultTextFontStyle()->setName(FontStyle::FONT_HELVETICA)->setHAlign(FontStyle::HORIZONTAL_ALIGN_MIDDLE);
// draw group labels
$graphic->getDefaultShapeStrokeStyle()->setColor('gray');
$graphic->addPath(getGroupPath(275, 280, 1, 118));
$graphic->addPathText('Meine Gruppe', getGroupPath(280, 280, 1, 118));
$graphic->addPath(getGroupPath(275, 280, 121, 118));
$graphic->addPathText('Meine andere Gruppe', getGroupPath(280, 280, 121, 118));
$graphic->addPath(getGroupPath(275, 280, 241, 118));
$graphic->addPathText('Meine dritte Gruppe', getGroupPath(280, 280, 241, 118));
// draw inner arcs
$graphic->getDefaultTextFontStyle()->setVAlign(FontStyle::VERTICAL_ALIGN_CENTRAL);
$graphic->getDefaultTextFillStyle()->setColor('white');
$graphic->getDefaultShapeFillStyle()->setColor(HtmlColor::rgb(236, 88, 85));
$graphic->getDefaultShapeStrokeStyle()->setColor('white');
for ($i = -4; $i < 25; $i++) {
    $arc = $graphic->addRingArc(0, 0, 6 * $i + 50, 240, 15 * $i, 15);
    $arc->setFillOpacity(($i + 8) / 32.0);
    $anchor = $arc->getAnchor(RingArc::ALPHA_CENTRAL, RingArc::RADIUS_MIDDLE);
    $graphic->addText($i, $anchor->x, $anchor->y);
    //->setRotation($anchor->getRotation());
}
// draw outer arcs
$graphic->addRingArc(0, 0, 240, 270, 0, 240)->setFillColor('rgb(81, 166, 74)');
$graphic->addRingArc(0, 0, 240, 270, 330, -30)->setFillColor('rgb(107, 178, 241)');
$graphic->addRingArc(0, 0, 240, 270, 330, 30)->setFillColor('rgb(69, 70, 77)', 0.3);
return $graphic;
Ejemplo n.º 4
0
 /**
  */
 public function testRgb()
 {
     $this->assertSame('#000000', HtmlColor::rgb(0, 0, 0)->__toString());
     $this->assertSame('#112233', HtmlColor::rgb(17, 34, 51)->__toString());
     $this->assertSame('#ffffff', HtmlColor::rgb(255, 255, 255)->__toString());
 }