Pop\Image\Svg::border PHP Метод

border() публичный Метод

Method to add a border to the image.
public border ( integer $w ) : Svg
$w integer
Результат Svg
    public function border($w)
    {
        $rect = $this->resource->addChild('rect');
        $rect->addAttribute('x', '0px');
        $rect->addAttribute('y', '0px');
        $rect->addAttribute('width', $this->width . $this->units);
        $rect->addAttribute('height', $this->height . $this->units);
        $color = null !== $this->strokeColor ? $this->strokeColor : new Rgb(0, 0, 0);
        $rect->addAttribute('stroke', $color->get(3, true));
        $rect->addAttribute('stroke-width', $w * 2 . $this->units);
        if (null !== $this->strokeDashLength && null !== $this->strokeDashGap) {
            $rect->addAttribute('stroke-dasharray', $this->strokeDashLength . $this->units . ',' . $this->strokeDashGap . $this->units);
        }
        $rect->addAttribute('fill', 'none');
        return $this;
    }

Usage Example

Пример #1
0
 public function testBorder()
 {
     $s = new Svg('graph.svg', '640px', '480px');
     $s->setStrokeWidth(5, 6, 4);
     $s->border(5);
     $this->assertEquals(640, $s->getWidth());
 }