PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.13.3
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.13.3
3.13.4 3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 All 262 releases
wpfunnels / vendor / intervention / image / src / Intervention / Image / Gd / Commands / FillCommand.php

FillCommand.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.13.3, at vendor/intervention/image/src/Intervention/Image/Gd/Commands/FillCommand.php

70 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Intervention\Image\Gd\Commands;
4
5 use Intervention\Image\Commands\AbstractCommand;
6 use Intervention\Image\Gd\Color;
7 use Intervention\Image\Gd\Decoder;
8
9 class FillCommand extends AbstractCommand
10 {
11 /**
12 * Fills image with color or pattern
13 *
14 * @param \Intervention\Image\Image $image
15 * @return boolean
16 */
17 public function execute($image)
18 {
19 $filling = $this->argument(0)->value();
20 $x = $this->argument(1)->type('digit')->value();
21 $y = $this->argument(2)->type('digit')->value();
22
23 $width = $image->getWidth();
24 $height = $image->getHeight();
25 $resource = $image->getCore();
26
27 try {
28
29 // set image tile filling
30 $source = new Decoder;
31 $tile = $source->init($filling);
32 imagesettile($image->getCore(), $tile->getCore());
33 $filling = IMG_COLOR_TILED;
34
35 } catch (\Intervention\Image\Exception\NotReadableException $e) {
36
37 // set solid color filling
38 $color = new Color($filling);
39 $filling = $color->getInt();
40 }
41
42 imagealphablending($resource, true);
43
44 if (is_int($x) && is_int($y)) {
45
46 // resource should be visible through transparency
47 $base = $image->getDriver()->newImage($width, $height)->getCore();
48 imagecopy($base, $resource, 0, 0, 0, 0, $width, $height);
49
50 // floodfill if exact position is defined
51 imagefill($resource, $x, $y, $filling);
52
53 // copy filled original over base
54 imagecopy($base, $resource, 0, 0, 0, 0, $width, $height);
55
56 // set base as new resource-core
57 $image->setCore($base);
58 imagedestroy($resource);
59
60 } else {
61 // fill whole image otherwise
62 imagefilledrectangle($resource, 0, 0, $width - 1, $height - 1, $filling);
63 }
64
65 isset($tile) ? imagedestroy($tile->getCore()) : null;
66
67 return true;
68 }
69 }
70