示例#1
0
 /**
  * @param float $x
  * @param float $y
  * @param float $radius
  */
 public function __construct($x, $y, $radius)
 {
     if ($radius <= 0.0) {
         throw new InvalidArgumentException(__CLASS__ . 'has to have a positive $radius');
     }
     parent::__construct();
     $this->x = (double) $x;
     $this->y = (double) $y;
     $this->radius = (double) $radius;
 }
示例#2
0
 /**
  * @param float $x
  * @param float $y
  * @param float $width
  * @param float $height
  */
 public function __construct($x, $y, $width, $height)
 {
     if ($width <= 0.0) {
         throw new InvalidArgumentException(__CLASS__ . 'has to have a positive width');
     }
     if ($height <= 0.0) {
         throw new InvalidArgumentException(__CLASS__ . 'has to have a positive height');
     }
     parent::__construct();
     $this->x = (double) $x;
     $this->y = (double) $y;
     $this->width = (double) $width;
     $this->height = (double) $height;
 }
示例#3
0
 /**
  * @param float $x
  * @param float $y
  * @param float $innerRadius
  * @param float $outerRadius
  * @param float $alpha
  * @param float $angle
  */
 public function __construct($x, $y, $innerRadius, $outerRadius, $alpha = 0.0, $angle = 360.0)
 {
     if ($innerRadius <= 0.0) {
         throw new InvalidArgumentException(__CLASS__ . 'has to have a positive $innerRadius');
     }
     if ($outerRadius < $innerRadius) {
         throw new InvalidArgumentException('$outerRadius has to be greater or equal to $innerRadius in ' . __CLASS__);
     }
     parent::__construct();
     $this->x = (double) $x;
     $this->y = (double) $y;
     $this->innerRadius = (double) $innerRadius;
     $this->outerRadius = (double) $outerRadius;
     if ($angle < 0.0) {
         $alpha += $angle;
         $angle = -$angle;
     }
     $this->alpha = $this->normalizeDegree((double) $alpha);
     $this->angle = $angle > 360.0 ? 360.0 : (double) $angle;
 }
 /**
  * @param AbstractShape $shape
  *
  * @return AbstractShape
  */
 private function addAndInitShape(AbstractShape $shape)
 {
     $shape->getFillStyle()->update($this->defaultShapeFillStyle);
     $shape->getStrokeStyle()->update($this->defaultShapeStrokeStyle);
     $this->add($shape);
     return $shape;
 }
示例#5
0
 /**
  * @param ZendPage $page
  * @param Path $path
  * @param AbstractShape $format
  */
 private function drawFormattedPath(ZendPage $page, Path $path, AbstractShape $format)
 {
     $fillStyle = $format->getFillStyle();
     $strokeStyle = $format->getStrokeStyle();
     $opacity = $format->getOpacity();
     if (!$fillStyle->isVisible()) {
         $this->setLineStyle($page, $strokeStyle, $opacity);
         $this->drawRawPath($page, $path, ZendPage::SHAPE_DRAW_STROKE);
     } elseif (!$strokeStyle->isVisible()) {
         $this->setFillStyle($page, $fillStyle, $opacity);
         $this->drawRawPath($page, $path, ZendPage::SHAPE_DRAW_FILL);
     } elseif ($fillStyle->getOpacity() !== 1.0 || $strokeStyle->getOpacity() !== 1.0) {
         // separate fill and stroke to emulate correct alpha behavior
         $this->setFillStyle($page, $fillStyle, $opacity);
         $this->drawRawPath($page, $path, ZendPage::SHAPE_DRAW_FILL);
         $this->setLineStyle($page, $strokeStyle, $opacity);
         $this->drawRawPath($page, $path, ZendPage::SHAPE_DRAW_STROKE);
     } else {
         $this->setLineStyle($page, $strokeStyle);
         $this->setFillStyle($page, $fillStyle);
         $page->setAlpha($opacity);
         $this->drawRawPath($page, $path, ZendPage::SHAPE_DRAW_FILL_AND_STROKE);
     }
 }
示例#6
0
 /**
  * @return bool
  */
 public function isVisible()
 {
     return parent::isVisible() && $this->getPath()->isVisible();
 }
 /**
  * @dataProvider getPathProvider
  *
  * @param AbstractShape $shape
  * @param Path|PathElement[] $path
  */
 public function testGetPath($shape, $path)
 {
     if ($path instanceof Path) {
         $this->assertSame($path, $shape->getPath());
     } else {
         $this->assertEquals($path, $shape->getPath()->getElements());
     }
 }
示例#8
0
 /**
  * @param SimpleXMLElement $element
  * @param AbstractShape $shape
  */
 private function addShapeStyle(SimpleXMLElement $element, AbstractShape $shape)
 {
     $this->addFillStyle($element, $shape->getFillStyle());
     $this->addStrokeStyle($element, $shape->getStrokeStyle());
     if ($shape->getOpacity() < 1) {
         $element->addAttribute("opacity", $shape->getOpacity());
     }
 }