Cheetah
EllipseShape.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use \Intervention\Image\Image;
6 use \Intervention\Image\Gd\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  // parse background color
47  $background = new Color($this->background);
48 
49  if ($this->hasBorder()) {
50  // slightly smaller ellipse to keep 1px bordered edges clean
51  imagefilledellipse($image->getCore(), $x, $y, $this->width-1, $this->height-1, $background->getInt());
52 
53  $border_color = new Color($this->border_color);
54  imagesetthickness($image->getCore(), $this->border_width);
55 
56  // gd's imageellipse doesn't respect imagesetthickness so i use imagearc with 359.9 degrees here
57  imagearc($image->getCore(), $x, $y, $this->width, $this->height, 0, 359.99, $border_color->getInt());
58  } else {
59  imagefilledellipse($image->getCore(), $x, $y, $this->width, $this->height, $background->getInt());
60  }
61 
62  return true;
63  }
64 }
Intervention\Image\Gd\Shapes\EllipseShape\$height
$height
Definition: EllipseShape.php:22
php
Intervention\Image\AbstractShape
Definition: AbstractShape.php:6
Intervention\Image\Image\getCore
getCore()
Definition: Image.php:186
Intervention\Image\Gd\Shapes\EllipseShape
Definition: EllipseShape.php:9
Intervention\Image\Gd\Shapes
Definition: CircleShape.php:3
Intervention\Image\Image
Definition: Image.php:50
Intervention\Image\Gd\Shapes\EllipseShape\$width
$width
Definition: EllipseShape.php:15
Intervention\Image\Gd\Shapes\EllipseShape\__construct
__construct($width=null, $height=null)
Definition: EllipseShape.php:30
Intervention\Image\AbstractShape\$border_color
$border_color
Definition: AbstractShape.php:19
Intervention\Image\Gd\Shapes\EllipseShape\applyToImage
applyToImage(Image $image, $x=0, $y=0)
Definition: EllipseShape.php:44
Intervention\Image\AbstractShape\$background
$background
Definition: AbstractShape.php:12
Intervention\Image\AbstractShape\hasBorder
hasBorder()
Definition: AbstractShape.php:67
Intervention\Image\Gd\Color
Definition: Color.php:8
Intervention\Image\AbstractShape\background
background($color)
Definition: AbstractShape.php:44