-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/font-system
- Loading branch information
Showing
28 changed files
with
837 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Intervention\Image\Drivers\Vips\Modifiers; | ||
|
||
use Intervention\Image\Drivers\Vips\Core; | ||
use Intervention\Image\Drivers\Vips\Driver; | ||
use Intervention\Image\Exceptions\RuntimeException; | ||
use Intervention\Image\Interfaces\ImageInterface; | ||
use Intervention\Image\Interfaces\SpecializedInterface; | ||
use Intervention\Image\Modifiers\DrawBezierModifier as GenericDrawBezierModifier; | ||
use Jcupitt\Vips\BlendMode; | ||
use Jcupitt\Vips\Exception as VipsException; | ||
|
||
class DrawBezierModifier extends GenericDrawBezierModifier implements SpecializedInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @see ModifierInterface::apply() | ||
* @throws VipsException|RuntimeException|\RuntimeException | ||
*/ | ||
public function apply(ImageInterface $image): ImageInterface | ||
{ | ||
$chunks = array_chunk($this->drawable->toArray(), 2); | ||
$points = join(' ', array_map(function (array $coordinates, int $key) use ($chunks): string { | ||
return match ($key) { | ||
0 => 'M' . join(' ', $coordinates), | ||
1 => count($chunks) === 3 ? 'Q' . join(' ', $coordinates) : 'C' . join(' ', $coordinates), | ||
default => join(' ', $coordinates), | ||
}; | ||
}, $chunks, array_keys($chunks))); | ||
|
||
$polygon = Driver::createShape( | ||
'path', | ||
[ | ||
'd' => $points, | ||
'fill' => $this->backgroundColor()->toString(), | ||
'stroke' => $this->borderColor()->toString(), | ||
'stroke-width' => $this->drawable->borderSize(), | ||
], | ||
$image->width(), | ||
$image->height(), | ||
); | ||
|
||
$frames = []; | ||
foreach ($image as $frame) { | ||
$frames[] = $frame->setNative( | ||
$frame->native()->composite($polygon->core()->native(), [BlendMode::OVER]) | ||
); | ||
} | ||
|
||
$image->core()->setNative( | ||
Core::replaceFrames($image->core()->native(), $frames) | ||
); | ||
|
||
return $image; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Intervention\Image\Drivers\Vips\Modifiers; | ||
|
||
use Intervention\Image\Drivers\Vips\Core; | ||
use Intervention\Image\Drivers\Vips\Driver; | ||
use Intervention\Image\Exceptions\RuntimeException; | ||
use Intervention\Image\Interfaces\ImageInterface; | ||
use Intervention\Image\Interfaces\SpecializedInterface; | ||
use Intervention\Image\Modifiers\DrawLineModifier as GenericDrawLineModifier; | ||
use Jcupitt\Vips\BlendMode; | ||
use Jcupitt\Vips\Exception as VipsException; | ||
|
||
class DrawLineModifier extends GenericDrawLineModifier implements SpecializedInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @see ModifierInterface::apply() | ||
* @throws VipsException|RuntimeException|\RuntimeException | ||
*/ | ||
public function apply(ImageInterface $image): ImageInterface | ||
{ | ||
$ellipse = Driver::createShape( | ||
'line', | ||
[ | ||
'x1' => $this->drawable->start()->x(), | ||
'y1' => $this->drawable->start()->y(), | ||
'x2' => $this->drawable->end()->x(), | ||
'y2' => $this->drawable->end()->y(), | ||
'stroke' => $this->backgroundColor()->toString(), | ||
'stroke-width' => $this->drawable->width(), | ||
], | ||
$image->width(), | ||
$image->height(), | ||
); | ||
|
||
$frames = []; | ||
foreach ($image as $frame) { | ||
$frames[] = $frame->setNative( | ||
$frame->native()->composite($ellipse->core()->native(), [BlendMode::OVER]) | ||
); | ||
} | ||
|
||
$image->core()->setNative( | ||
Core::replaceFrames($image->core()->native(), $frames) | ||
); | ||
|
||
return $image; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Intervention\Image\Drivers\Vips\Modifiers; | ||
|
||
use Intervention\Image\Drivers\Vips\Core; | ||
use Intervention\Image\Exceptions\AnimationException; | ||
use Intervention\Image\Exceptions\ColorException; | ||
use Intervention\Image\Exceptions\RuntimeException; | ||
use Intervention\Image\Interfaces\ImageInterface; | ||
use Intervention\Image\Interfaces\SpecializedInterface; | ||
use Intervention\Image\Modifiers\DrawPixelModifier as GenericDrawPixelModifier; | ||
use Jcupitt\Vips\BlendMode; | ||
use Jcupitt\Vips\Image as VipsImage; | ||
use Jcupitt\Vips\Exception as VipsException; | ||
|
||
class DrawPixelModifier extends GenericDrawPixelModifier implements SpecializedInterface | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @throws VipsException|AnimationException|ColorException|RuntimeException | ||
* @see Intervention\Image\Interfaces\ModifierInterface::apply() | ||
*/ | ||
public function apply(ImageInterface $image): ImageInterface | ||
{ | ||
// decode pixel color | ||
$color = $this->driver()->colorProcessor($image->colorspace())->colorToNative( | ||
$this->driver()->handleInput($this->color) | ||
); | ||
|
||
$pixel = VipsImage::black(1, 1) | ||
->add($color[0]) // red | ||
->cast($image->core()->native()->format) | ||
->copy(['interpretation' => $image->core()->native()->interpretation]) | ||
->bandjoin([ | ||
$color[1], // green | ||
$color[2], // blue | ||
$color[3], // alpha | ||
]); | ||
|
||
$frames = []; | ||
foreach ($image as $frame) { | ||
$frames[] = $frame->setNative( | ||
$frame->native()->composite2( | ||
$pixel, | ||
BlendMode::OVER, | ||
[ | ||
'x' => $this->position->x(), | ||
'y' => $this->position->y(), | ||
], | ||
) | ||
); | ||
} | ||
|
||
$image->core()->setNative( | ||
Core::replaceFrames($image->core()->native(), $frames) | ||
); | ||
|
||
return $image; | ||
} | ||
} |
Oops, something went wrong.