/** * @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); } }
/** * @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; }
/** * @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()); } }