示例#1
0
 public function draw(SVGRenderingHelper $rh, $scaleX, $scaleY, $offsetX = 0, $offsetY = 0)
 {
     $rh->push();
     $opacity = $this->getStyle('opacity');
     if (isset($opacity) && is_numeric($opacity)) {
         $opacity = floatval($opacity);
         $rh->scaleOpacity($opacity);
     }
     // original (document fragment) width for unit parsing
     $ow = $rh->getWidth() / $scaleX;
     $p = array();
     $np = count($this->points);
     for ($i = 0; $i < $np; $i++) {
         $point = $this->points[$i];
         $p[] = ($offsetX + $point[0]) * $scaleX;
         $p[] = ($offsetY + $point[1]) * $scaleY;
     }
     $fill = $this->getComputedStyle('fill');
     if (isset($fill) && $fill !== 'none') {
         $fillColor = SVG::parseColor($fill, true);
         $rh->fillPolygon($p, $np, $fillColor);
     }
     $stroke = $this->getComputedStyle('stroke');
     if (isset($stroke) && $stroke !== 'none') {
         $strokeColor = SVG::parseColor($stroke, true);
         $rh->setStrokeWidth(SVG::convertUnit($this->getComputedStyle('stroke-width'), $ow) * $scaleX);
         $rh->drawPolygon($p, $np, $strokeColor);
     }
     $rh->pop();
 }