Line.php 777 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Grafika\Imagick\DrawingObject;
  3. use Grafika\DrawingObject\Line as Base;
  4. use Grafika\DrawingObjectInterface;
  5. use Grafika\Imagick\Image;
  6. /**
  7. * Class Line
  8. * @package Grafika
  9. */
  10. class Line extends Base implements DrawingObjectInterface
  11. {
  12. /**
  13. * @param Image $image
  14. *
  15. * @return Image
  16. */
  17. public function draw($image)
  18. {
  19. $strokeColor = new \ImagickPixel($this->getColor()->getHexString());
  20. $draw = new \ImagickDraw();
  21. $draw->setStrokeColor($strokeColor);
  22. $draw->setStrokeWidth($this->thickness);
  23. list($x1, $y1) = $this->point1;
  24. list($x2, $y2) = $this->point2;
  25. $draw->line($x1, $y1, $x2, $y2);
  26. $image->getCore()->drawImage($draw);
  27. return $image;
  28. }
  29. }