Cheetah
EllipseShape.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use \Intervention\Image\Image;
6 use \Intervention\Image\Imagick\Color;
7 
9 {
15  public $width = 100;
16 
22  public $height = 100;
23 
30  public function __construct($width = null, $height = null)
31  {
32  $this->width = is_numeric($width) ? intval($width) : $this->width;
33  $this->height = is_numeric($height) ? intval($height) : $this->height;
34  }
35 
44  public function applyToImage(Image $image, $x = 0, $y = 0)
45  {
46  $circle = new \ImagickDraw;
47 
48  // set background
49  $bgcolor = new Color($this->background);
50  $circle->setFillColor($bgcolor->getPixel());
51 
52  // set border
53  if ($this->hasBorder()) {
54  $border_color = new Color($this->border_color);
55  $circle->setStrokeWidth($this->border_width);
56  $circle->setStrokeColor($border_color->getPixel());
57  }
58 
59  $circle->ellipse($x, $y, $this->width / 2, $this->height / 2, 0, 360);
60 
61  $image->getCore()->drawImage($circle);
62 
63  return true;
64  }
65 }
Intervention\Image\Imagick\Shapes\EllipseShape\applyToImage
applyToImage(Image $image, $x=0, $y=0)
Definition: EllipseShape.php:44
Intervention\Image\Imagick\Shapes\EllipseShape\$height
$height
Definition: EllipseShape.php:22
Intervention\Image\Imagick\Shapes\EllipseShape
Definition: EllipseShape.php:9
Intervention\Image\Imagick\Color
Definition: Color.php:6
php
Intervention\Image\AbstractShape
Definition: AbstractShape.php:6
Intervention\Image\Image\getCore
getCore()
Definition: Image.php:186
Intervention\Image\Imagick\Shapes
Definition: CircleShape.php:3
Intervention\Image\Imagick\Shapes\EllipseShape\$width
$width
Definition: EllipseShape.php:15
Intervention\Image\Image
Definition: Image.php:50
Intervention\Image\AbstractShape\$border_color
$border_color
Definition: AbstractShape.php:19
Intervention\Image\Imagick\Shapes\EllipseShape\__construct
__construct($width=null, $height=null)
Definition: EllipseShape.php:30
Intervention\Image\AbstractShape\hasBorder
hasBorder()
Definition: AbstractShape.php:67
Intervention\Image\AbstractShape\background
background($color)
Definition: AbstractShape.php:44