-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathRotateModifier.php
More file actions
41 lines (35 loc) Β· 982 Bytes
/
RotateModifier.php
File metadata and controls
41 lines (35 loc) Β· 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
declare(strict_types=1);
namespace Intervention\Image\Modifiers;
use Intervention\Image\Drivers\SpecializableModifier;
use Intervention\Image\Exceptions\StateException;
use Intervention\Image\Interfaces\ColorInterface;
class RotateModifier extends SpecializableModifier
{
public function __construct(
public float $angle,
public null|string|ColorInterface $background = null,
) {
//
}
/**
* Clockwise rotation angle.
*
* Restricted beyond 360 degrees because the end result is the same.
*/
public function rotationAngle(): float
{
return fmod($this->angle, 360);
}
/**
* Return color to fill the newly created areas after rotation.
*
* @throws StateException
*/
protected function backgroundColor(): ColorInterface
{
return $this->driver()->decodeColor(
$this->background ?? $this->driver()->config()->backgroundColor,
);
}
}