Cheetah
RectangleShape.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 $x1 = 0;
16 
22  public $y1 = 0;
23 
29  public $x2 = 0;
30 
36  public $y2 = 0;
37 
46  public function __construct($x1 = null, $y1 = null, $x2 = null, $y2 = null)
47  {
48  $this->x1 = is_numeric($x1) ? intval($x1) : $this->x1;
49  $this->y1 = is_numeric($y1) ? intval($y1) : $this->y1;
50  $this->x2 = is_numeric($x2) ? intval($x2) : $this->x2;
51  $this->y2 = is_numeric($y2) ? intval($y2) : $this->y2;
52  }
53 
62  public function applyToImage(Image $image, $x = 0, $y = 0)
63  {
64  $background = new Color($this->background);
65  imagefilledrectangle($image->getCore(), $this->x1, $this->y1, $this->x2, $this->y2, $background->getInt());
66 
67  if ($this->hasBorder()) {
68  $border_color = new Color($this->border_color);
69  imagesetthickness($image->getCore(), $this->border_width);
70  imagerectangle($image->getCore(), $this->x1, $this->y1, $this->x2, $this->y2, $border_color->getInt());
71  }
72 
73  return true;
74  }
75 }
Intervention\Image\Gd\Shapes\RectangleShape\applyToImage
applyToImage(Image $image, $x=0, $y=0)
Definition: RectangleShape.php:62
php
Intervention\Image\Gd\Shapes\RectangleShape\__construct
__construct($x1=null, $y1=null, $x2=null, $y2=null)
Definition: RectangleShape.php:46
Intervention\Image\AbstractShape
Definition: AbstractShape.php:6
Intervention\Image\Gd\Shapes\RectangleShape\$x1
$x1
Definition: RectangleShape.php:15
Intervention\Image\Gd\Shapes\RectangleShape\$y1
$y1
Definition: RectangleShape.php:22
Intervention\Image\Image\getCore
getCore()
Definition: Image.php:186
Intervention\Image\Gd\Shapes\RectangleShape\$x2
$x2
Definition: RectangleShape.php:29
Intervention\Image\Gd\Shapes
Definition: CircleShape.php:3
Intervention\Image\Image
Definition: Image.php:50
Intervention\Image\Gd\Shapes\RectangleShape
Definition: RectangleShape.php:9
Intervention\Image\AbstractShape\$border_color
$border_color
Definition: AbstractShape.php:19
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
Intervention\Image\Gd\Shapes\RectangleShape\$y2
$y2
Definition: RectangleShape.php:36