Ellipse.php 992 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace Grafika\Imagick\DrawingObject;
  3. use Grafika\DrawingObject\Ellipse as Base;
  4. use Grafika\DrawingObjectInterface;
  5. use Grafika\ImageInterface;
  6. /**
  7. * Class Ellipse
  8. * @package Grafika
  9. */
  10. class Ellipse extends Base implements DrawingObjectInterface
  11. {
  12. /**
  13. * @param ImageInterface $image
  14. * @return ImageInterface
  15. */
  16. public function draw($image)
  17. {
  18. $strokeColor = new \ImagickPixel($this->getBorderColor()->getHexString());
  19. $fillColor = new \ImagickPixel($this->getFillColor()->getHexString());
  20. $draw = new \ImagickDraw();
  21. $draw->setStrokeColor($strokeColor);
  22. $draw->setFillColor($fillColor);
  23. $draw->setStrokeWidth($this->borderSize);
  24. list($x, $y) = $this->pos;
  25. $left = $x + $this->width / 2;
  26. $top = $y + $this->height / 2;
  27. $draw->ellipse($left, $top, $this->width/2, $this->height/2, 0, 360);
  28. $image->getCore()->drawImage($draw);
  29. return $image;
  30. }
  31. }