diff --git a/src/Drivers/Abstract/AbstractImage.php b/src/Drivers/Abstract/AbstractImage.php index 23637795..1bb8502a 100644 --- a/src/Drivers/Abstract/AbstractImage.php +++ b/src/Drivers/Abstract/AbstractImage.php @@ -261,4 +261,11 @@ abstract class AbstractImage ) ); } + + public function rotate(float $angle, $backgroundColor = null): ImageInterface + { + return $this->modify( + $this->resolveDriverClass('Modifiers\RotateModifier', $angle, $backgroundColor) + ); + } } diff --git a/src/Drivers/Gd/Modifiers/RotateModifier.php b/src/Drivers/Gd/Modifiers/RotateModifier.php index 6c8b507a..c5276e4d 100644 --- a/src/Drivers/Gd/Modifiers/RotateModifier.php +++ b/src/Drivers/Gd/Modifiers/RotateModifier.php @@ -5,9 +5,12 @@ namespace Intervention\Image\Drivers\Gd\Modifiers; use Intervention\Image\Interfaces\FrameInterface; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Interfaces\ModifierInterface; +use Intervention\Image\Traits\CanHandleInput; class RotateModifier implements ModifierInterface { + use CanHandleInput; + /** * Rotation angle * @@ -20,23 +23,25 @@ class RotateModifier implements ModifierInterface * * @var mixed */ - protected $backgroundcolor; + protected $backgroundColor; /** * Create new modifier * * @param float $angle */ - public function __construct(float $angle, $backgroundcolor = null) + public function __construct(float $angle, $backgroundColor = null) { $this->angle = $angle; - $this->backgroundcolor = $backgroundcolor; + $this->backgroundColor = $backgroundColor; } public function apply(ImageInterface $image): ImageInterface { foreach ($image as $frame) { - imagerotate($frame->getCore(), $this->rotationAngle(), 0); + $frame->setCore( + imagerotate($frame->getCore(), $this->rotationAngle(), $this->backgroundColor()) + ); } return $image; @@ -47,4 +52,14 @@ class RotateModifier implements ModifierInterface // restrict rotations beyond 360 degrees, since the end result is the same return fmod($this->angle, 360); } + + protected function backgroundColor(): int + { + $color = $this->handleInput($this->backgroundColor); + + echo "
";
+        var_dump($color);
+        echo "
"; + exit; + } } diff --git a/src/Traits/CanHandleInput.php b/src/Traits/CanHandleInput.php new file mode 100644 index 00000000..42edc18a --- /dev/null +++ b/src/Traits/CanHandleInput.php @@ -0,0 +1,16 @@ +resolveDriverClass('InputHandler')->handle($input); + } +}