$point1
$point1 : array
X,Y pos 1.
Class Line
$color : \Grafika\Color
__construct(array $point1, array $point2, integer $thickness = 1, \Grafika\Color|string $color = '#000000')
Creates a line.
array | $point1 | Array containing int X and int Y position of the starting point. |
array | $point2 | Array containing int X and int Y position of the starting point. |
integer | $thickness | Thickness in pixel. Note: This is currently ignored in GD editor and falls back to 1. |
\Grafika\Color|string | $color | Color of the line. Defaults to black. |
getColor() : \Grafika\Color
draw(\Grafika\Imagick\Image $image) : \Grafika\Imagick\Image
\Grafika\Imagick\Image | $image |
<?php
namespace Grafika\Imagick\DrawingObject;
use Grafika\DrawingObject\Line as Base;
use Grafika\DrawingObjectInterface;
use Grafika\Imagick\Image;
/**
* Class Line
* @package Grafika
*/
class Line extends Base implements DrawingObjectInterface
{
/**
* @param Image $image
*
* @return Image
*/
public function draw($image)
{
$strokeColor = new \ImagickPixel($this->getColor()->getHexString());
$draw = new \ImagickDraw();
$draw->setStrokeColor($strokeColor);
$draw->setStrokeWidth($this->thickness);
list($x1, $y1) = $this->point1;
list($x2, $y2) = $this->point2;
$draw->line($x1, $y1, $x2, $y2);
$image->getCore()->drawImage($draw);
return $image;
}
}