コード例 #1
0
ファイル: SVGLine.php プロジェクト: ilya3d/php-svg
 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;
     $x1 = ($offsetX + $this->x1) * $scaleX;
     $y1 = ($offsetY + $this->y1) * $scaleY;
     $x2 = ($offsetX + $this->x2) * $scaleX;
     $y2 = ($offsetY + $this->y2) * $scaleY;
     $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->drawLine($x1, $y1, $x2, $y2, $strokeColor);
     }
     $rh->pop();
 }