示例#1
0
 protected function before($attribs)
 {
     $surface = $this->document->getSurface();
     $surface->save();
     $style = new Style();
     $style->inherit($this);
     $style->fromAttributes($attribs);
     $this->setStyle($style);
     $surface->setStyle($style);
     $this->applyTransform($attribs);
 }
示例#2
0
 public function getStops()
 {
     if (empty($this->stops)) {
         foreach ($this->children as $_child) {
             if ($_child->tagName != "stop") {
                 continue;
             }
             $_stop = new Stop();
             $_attributes = $_child->attributes;
             // Style
             if (isset($_attributes["style"])) {
                 $_style = Style::parseCssStyle($_attributes["style"]);
                 if (isset($_style["stop-color"])) {
                     $_stop->color = Style::parseColor($_style["stop-color"]);
                 }
                 if (isset($_style["stop-opacity"])) {
                     $_stop->opacity = max(0, min(1.0, $_style["stop-opacity"]));
                 }
             }
             // Attributes
             if (isset($_attributes["offset"])) {
                 $_stop->offset = $_attributes["offset"];
             }
             if (isset($_attributes["stop-color"])) {
                 $_stop->color = Style::parseColor($_attributes["stop-color"]);
             }
             if (isset($_attributes["stop-opacity"])) {
                 $_stop->opacity = max(0, min(1.0, $_attributes["stop-opacity"]));
             }
             $this->stops[] = $_stop;
         }
     }
     return $this->stops;
 }
示例#3
0
 public function test_convertSize()
 {
     $this->assertEquals(1, Style::convertSize(1));
     $this->assertEquals(10, Style::convertSize("10px"));
     // FIXME
     $this->assertEquals(10, Style::convertSize("10pt"));
     $this->assertEquals(8, Style::convertSize("80%", 72, 10));
 }
示例#4
0
 public function handleSizeAttributes($attributes)
 {
     if ($this->width === null) {
         if (isset($attributes["width"])) {
             $width = Style::convertSize($attributes["width"], 400);
             $this->width = $width;
         }
         if (isset($attributes["height"])) {
             $height = Style::convertSize($attributes["height"], 300);
             $this->height = $height;
         }
         if (isset($attributes['viewbox'])) {
             $viewBox = preg_split('/[\\s,]+/is', trim($attributes['viewbox']));
             if (count($viewBox) == 4) {
                 $this->x = $viewBox[0];
                 $this->y = $viewBox[1];
                 if (!$this->width) {
                     $this->width = $viewBox[2];
                 }
                 if (!$this->height) {
                     $this->height = $viewBox[3];
                 }
             }
         }
     }
     return array(0 => $this->width, 1 => $this->height, "width" => $this->width, "height" => $this->height);
 }
示例#5
0
 /**
  * Make a style object from the tag and its attributes
  *
  * @param array $attributes
  *
  * @return Style
  */
 protected function makeStyle($attributes)
 {
     $style = new Style();
     $style->inherit($this);
     $style->fromStyleSheets($this, $attributes);
     $style->fromAttributes($attributes);
     return $style;
 }