Pop\Image\Gd::drawLine PHP Метод

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

Method to add a line to the image.
public drawLine ( integer $x1, integer $y1, integer $x2, integer $y2 ) : Gd
$x1 integer
$y1 integer
$x2 integer
$y2 integer
Результат Gd
    public function drawLine($x1, $y1, $x2, $y2)
    {
        // Create an image resource and set the stroke color.
        $this->createResource();
        $strokeWidth = null === $this->strokeWidth ? 1 : $this->strokeWidth;
        $strokeColor = null === $this->strokeColor ? $this->setColor(new Rgb(0, 0, 0)) : $this->setColor($this->strokeColor);
        // Draw the line.
        imagesetthickness($this->resource, $strokeWidth);
        imageline($this->resource, $x1, $y1, $x2, $y2, $strokeColor);
        $this->output = $this->resource;
        return $this;
    }

Usage Example

Пример #1
0
 public function testAddLine()
 {
     $i = new Gd(__DIR__ . '/../tmp/test.jpg');
     $i->drawLine(10, 10, 100, 100);
     $this->assertEquals(640, $i->getWidth());
 }