mirror of
https://github.com/Intervention/image.git
synced 2025-08-29 16:50:07 +02:00
Fill modifier filling
This commit is contained in:
@@ -6,11 +6,11 @@ use Intervention\Image\Drivers\Gd\InputHandler;
|
||||
use Intervention\Image\Interfaces\FrameInterface;
|
||||
use Intervention\Image\Interfaces\ImageInterface;
|
||||
use Intervention\Image\Interfaces\ModifierInterface;
|
||||
use Intervention\Image\Traits\CanHandleInput;
|
||||
use Intervention\Image\Traits\CanResolveDriverClass;
|
||||
|
||||
class FillModifier implements ModifierInterface
|
||||
{
|
||||
use CanHandleInput;
|
||||
use CanResolveDriverClass;
|
||||
|
||||
public function __construct($filling, ?int $x = null, ?int $y = null)
|
||||
{
|
||||
@@ -21,7 +21,7 @@ class FillModifier implements ModifierInterface
|
||||
{
|
||||
$width = $image->getWidth();
|
||||
$height = $image->getHeight();
|
||||
$filling = $this->handleInput($this->filling);
|
||||
$filling = $this->getApplicableFilling();
|
||||
|
||||
foreach ($image as $frame) {
|
||||
imagefilledrectangle($frame->getCore(), 0, 0, $width - 1, $height - 1, $filling);
|
||||
@@ -29,4 +29,9 @@ class FillModifier implements ModifierInterface
|
||||
|
||||
return $image;
|
||||
}
|
||||
|
||||
protected function getApplicableFilling(): ColorInterface
|
||||
{
|
||||
return $this->resolveDriverClass('InputHandler')->handle($this->filling);
|
||||
}
|
||||
}
|
||||
|
@@ -4,13 +4,14 @@ namespace Intervention\Image\Drivers\Imagick\Modifiers;
|
||||
|
||||
use ImagickDraw;
|
||||
use Intervention\Image\Drivers\Imagick\InputHandler;
|
||||
use Intervention\Image\Interfaces\ColorInterface;
|
||||
use Intervention\Image\Interfaces\ImageInterface;
|
||||
use Intervention\Image\Interfaces\ModifierInterface;
|
||||
use Intervention\Image\Traits\CanHandleInput;
|
||||
use Intervention\Image\Traits\CanResolveDriverClass;
|
||||
|
||||
class FillModifier implements ModifierInterface
|
||||
{
|
||||
use CanHandleInput;
|
||||
use CanResolveDriverClass;
|
||||
|
||||
public function __construct($filling, ?int $x = null, ?int $y = null)
|
||||
{
|
||||
@@ -19,7 +20,7 @@ class FillModifier implements ModifierInterface
|
||||
|
||||
public function apply(ImageInterface $image): ImageInterface
|
||||
{
|
||||
$filling = $this->handleInput($this->filling);
|
||||
$filling = $this->getApplicableFilling();
|
||||
|
||||
$draw = new ImagickDraw();
|
||||
$draw->setFillColor($filling->getPixel());
|
||||
@@ -31,4 +32,9 @@ class FillModifier implements ModifierInterface
|
||||
|
||||
return $image;
|
||||
}
|
||||
|
||||
protected function getApplicableFilling(): ColorInterface
|
||||
{
|
||||
return $this->resolveDriverClass('InputHandler')->handle($this->filling);
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Intervention\Image\Traits;
|
||||
|
||||
trait CanHandleInput
|
||||
{
|
||||
protected function handleInput($value)
|
||||
{
|
||||
return (new InputHandler())->handle($value);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user