Пример #1
0
 /**
  */
 public function testUpdate()
 {
     $style1 = new StrokeStyle();
     $style2 = new StrokeStyle(2.5, 'green', 0.6);
     $style1->update($style2);
     $this->assertSame(2.5, $style1->getWidth());
     $this->assertSame(0.6, $style1->getOpacity());
     $this->assertNotNull($style1->getColor());
     $this->assertSame('green', $style1->getColor()->__toString());
     // test independence of style1 and style2
     $style1->setOpacity(0.3);
     $this->assertSame(0.3, $style1->getOpacity());
     $this->assertSame(0.6, $style2->getOpacity());
 }
Пример #2
0
 /**
  * @param ZendPage $page
  * @param StrokeStyle $strokeStyle
  * @param float|null $opacity
  */
 private function setLineStyle(ZendPage $page, StrokeStyle $strokeStyle, $opacity = null)
 {
     $page->setLineWidth($strokeStyle->getWidth());
     $page->setLineColor($this->getZendColor($strokeStyle->getColor()));
     if ($opacity !== null) {
         $page->setAlpha($opacity * $strokeStyle->getOpacity());
     }
 }
Пример #3
0
 /**
  * @param SimpleXMLElement $element
  * @param StrokeStyle $strokeStyle
  */
 private function addStrokeStyle(SimpleXMLElement $element, StrokeStyle $strokeStyle)
 {
     if ($strokeStyle->isVisible()) {
         $element->addAttribute("stroke", $strokeStyle->getColor());
         $element->addAttribute("stroke-opacity", $strokeStyle->getOpacity());
         $element->addAttribute("stroke-width", $strokeStyle->getWidth());
     } else {
         $element->addAttribute("stroke", "none");
     }
 }