Cheetah
FillCommand.php
Go to the documentation of this file.
1 <?php
2 
4 
7 
9 {
16  public function execute($image)
17  {
18  $filling = $this->argument(0)->value();
19  $x = $this->argument(1)->type('digit')->value();
20  $y = $this->argument(2)->type('digit')->value();
21 
22  $width = $image->getWidth();
23  $height = $image->getHeight();
24  $resource = $image->getCore();
25 
26  try {
27 
28  // set image tile filling
29  $source = new Decoder;
30  $tile = $source->init($filling);
31  imagesettile($image->getCore(), $tile->getCore());
32  $filling = IMG_COLOR_TILED;
33 
34  } catch (\Intervention\Image\Exception\NotReadableException $e) {
35 
36  // set solid color filling
37  $color = new Color($filling);
38  $filling = $color->getInt();
39  }
40 
41  imagealphablending($resource, true);
42 
43  if (is_int($x) && is_int($y)) {
44 
45  // resource should be visible through transparency
46  $base = $image->getDriver()->newImage($width, $height)->getCore();
47  imagecopy($base, $resource, 0, 0, 0, 0, $width, $height);
48 
49  // floodfill if exact position is defined
50  imagefill($resource, $x, $y, $filling);
51 
52  // copy filled original over base
53  imagecopy($base, $resource, 0, 0, 0, 0, $width, $height);
54 
55  // set base as new resource-core
56  $image->setCore($base);
57  imagedestroy($resource);
58 
59  } else {
60  // fill whole image otherwise
61  imagefilledrectangle($resource, 0, 0, $width - 1, $height - 1, $filling);
62  }
63 
64  isset($tile) ? imagedestroy($tile->getCore()) : null;
65 
66  return true;
67  }
68 }
Intervention\Image\Gd\Commands\FillCommand
Definition: FillCommand.php:9
Intervention\Image\Gd\Commands
Definition: BackupCommand.php:3
use
GNU LESSER GENERAL PUBLIC LICENSE February Free Software Inc Franklin Fifth MA USA Everyone is permitted to copy and distribute verbatim copies of this license but changing it is not allowed[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it By the GNU General Public Licenses are intended to guarantee your freedom to share and change free software to make sure the software is free for all its users This the Lesser General Public applies to some specially designated software packages typically libraries of the Free Software Foundation and other authors who decide to use it You can use it but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular based on the explanations below When we speak of free we are referring to freedom of use
Definition: license.txt:27
php
Intervention\Image\Gd\Commands\FillCommand\execute
execute($image)
Definition: FillCommand.php:16
Intervention\Image\Image
Definition: Image.php:50
Intervention\Image\Commands\AbstractCommand\argument
argument($key)
Definition: AbstractCommand.php:45
Intervention\Image\AbstractDecoder\init
init($data)
Definition: AbstractDecoder.php:257
Intervention\Image\Commands\AbstractCommand
Definition: AbstractCommand.php:6
Intervention\Image\Gd\Color
Definition: Color.php:8
Intervention\Image\Gd\Decoder
Definition: Decoder.php:9
Intervention