mirror of
https://github.com/Intervention/image.git
synced 2025-09-02 18:32:56 +02:00
Rename method
- ImageInterface::eachFrame to ImageInterface::mapFrames
This commit is contained in:
@@ -29,7 +29,7 @@ abstract class AbstractImage implements ImageInterface
|
|||||||
protected ColorspaceInterface $colorspace;
|
protected ColorspaceInterface $colorspace;
|
||||||
protected Collection $exif;
|
protected Collection $exif;
|
||||||
|
|
||||||
public function eachFrame(callable $callback): ImageInterface
|
public function mapFrames(callable $callback): ImageInterface
|
||||||
{
|
{
|
||||||
foreach ($this as $frame) {
|
foreach ($this as $frame) {
|
||||||
$callback($frame);
|
$callback($frame);
|
||||||
|
@@ -13,7 +13,7 @@ class DrawEllipseModifier extends AbstractDrawModifier implements ModifierInterf
|
|||||||
|
|
||||||
public function apply(ImageInterface $image): ImageInterface
|
public function apply(ImageInterface $image): ImageInterface
|
||||||
{
|
{
|
||||||
return $image->eachFrame(function ($frame) {
|
return $image->mapFrames(function ($frame) {
|
||||||
if ($this->ellipse()->hasBorder()) {
|
if ($this->ellipse()->hasBorder()) {
|
||||||
// slightly smaller ellipse to keep 1px bordered edges clean
|
// slightly smaller ellipse to keep 1px bordered edges clean
|
||||||
if ($this->ellipse()->hasBackgroundColor()) {
|
if ($this->ellipse()->hasBackgroundColor()) {
|
||||||
|
@@ -13,7 +13,7 @@ class DrawLineModifier extends AbstractDrawModifier implements ModifierInterface
|
|||||||
|
|
||||||
public function apply(ImageInterface $image): ImageInterface
|
public function apply(ImageInterface $image): ImageInterface
|
||||||
{
|
{
|
||||||
return $image->eachFrame(function ($frame) {
|
return $image->mapFrames(function ($frame) {
|
||||||
imageline(
|
imageline(
|
||||||
$frame->getCore(),
|
$frame->getCore(),
|
||||||
$this->line()->getStart()->getX(),
|
$this->line()->getStart()->getX(),
|
||||||
|
@@ -23,7 +23,7 @@ class DrawPixelModifier implements ModifierInterface
|
|||||||
public function apply(ImageInterface $image): ImageInterface
|
public function apply(ImageInterface $image): ImageInterface
|
||||||
{
|
{
|
||||||
$color = $this->handleInput($this->color);
|
$color = $this->handleInput($this->color);
|
||||||
return $image->eachFrame(function ($frame) use ($color) {
|
return $image->mapFrames(function ($frame) use ($color) {
|
||||||
imagesetpixel(
|
imagesetpixel(
|
||||||
$frame->getCore(),
|
$frame->getCore(),
|
||||||
$this->position->getX(),
|
$this->position->getX(),
|
||||||
|
@@ -20,7 +20,7 @@ class DrawPolygonModifier extends AbstractDrawModifier implements ModifierInterf
|
|||||||
|
|
||||||
public function apply(ImageInterface $image): ImageInterface
|
public function apply(ImageInterface $image): ImageInterface
|
||||||
{
|
{
|
||||||
return $image->eachFrame(function ($frame) {
|
return $image->mapFrames(function ($frame) {
|
||||||
if ($this->polygon()->hasBackgroundColor()) {
|
if ($this->polygon()->hasBackgroundColor()) {
|
||||||
imagefilledpolygon(
|
imagefilledpolygon(
|
||||||
$frame->getCore(),
|
$frame->getCore(),
|
||||||
|
@@ -13,7 +13,7 @@ class DrawRectangleModifier extends AbstractDrawModifier implements ModifierInte
|
|||||||
|
|
||||||
public function apply(ImageInterface $image): ImageInterface
|
public function apply(ImageInterface $image): ImageInterface
|
||||||
{
|
{
|
||||||
$image->eachFrame(function ($frame) {
|
$image->mapFrames(function ($frame) {
|
||||||
// draw background
|
// draw background
|
||||||
if ($this->rectangle()->hasBackgroundColor()) {
|
if ($this->rectangle()->hasBackgroundColor()) {
|
||||||
imagefilledrectangle(
|
imagefilledrectangle(
|
||||||
|
@@ -18,7 +18,7 @@ class DrawEllipseModifier extends AbstractDrawModifier implements ModifierInterf
|
|||||||
$background_color = $this->colorToPixel($this->getBackgroundColor(), $colorspace);
|
$background_color = $this->colorToPixel($this->getBackgroundColor(), $colorspace);
|
||||||
$border_color = $this->colorToPixel($this->getBorderColor(), $colorspace);
|
$border_color = $this->colorToPixel($this->getBorderColor(), $colorspace);
|
||||||
|
|
||||||
return $image->eachFrame(function ($frame) use ($background_color, $border_color) {
|
return $image->mapFrames(function ($frame) use ($background_color, $border_color) {
|
||||||
$drawing = new ImagickDraw();
|
$drawing = new ImagickDraw();
|
||||||
$drawing->setFillColor($background_color);
|
$drawing->setFillColor($background_color);
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@ class DrawLineModifier extends AbstractDrawModifier implements ModifierInterface
|
|||||||
$this->line()->getEnd()->getY(),
|
$this->line()->getEnd()->getY(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return $image->eachFrame(function ($frame) use ($drawing) {
|
return $image->mapFrames(function ($frame) use ($drawing) {
|
||||||
$frame->getCore()->drawImage($drawing);
|
$frame->getCore()->drawImage($drawing);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,7 @@ class DrawPixelModifier implements ModifierInterface
|
|||||||
$pixel->setFillColor($this->colorToPixel($color, $image->getColorspace()));
|
$pixel->setFillColor($this->colorToPixel($color, $image->getColorspace()));
|
||||||
$pixel->point($this->position->getX(), $this->position->getY());
|
$pixel->point($this->position->getX(), $this->position->getY());
|
||||||
|
|
||||||
return $image->eachFrame(function ($frame) use ($pixel) {
|
return $image->mapFrames(function ($frame) use ($pixel) {
|
||||||
$frame->getCore()->drawImage($pixel);
|
$frame->getCore()->drawImage($pixel);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -37,7 +37,7 @@ class DrawPolygonModifier extends AbstractDrawModifier implements ModifierInterf
|
|||||||
|
|
||||||
$drawing->polygon($this->points());
|
$drawing->polygon($this->points());
|
||||||
|
|
||||||
return $image->eachFrame(function ($frame) use ($drawing) {
|
return $image->mapFrames(function ($frame) use ($drawing) {
|
||||||
$frame->getCore()->drawImage($drawing);
|
$frame->getCore()->drawImage($drawing);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -33,10 +33,8 @@ class DrawRectangleModifier extends AbstractDrawModifier implements ModifierInte
|
|||||||
$this->position->getY() + $this->rectangle()->bottomRightPoint()->getY()
|
$this->position->getY() + $this->rectangle()->bottomRightPoint()->getY()
|
||||||
);
|
);
|
||||||
|
|
||||||
$image->eachFrame(function ($frame) use ($drawing) {
|
return $image->mapFrames(function ($frame) use ($drawing) {
|
||||||
$frame->getCore()->drawImage($drawing);
|
$frame->getCore()->drawImage($drawing);
|
||||||
});
|
});
|
||||||
|
|
||||||
return $image;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -31,7 +31,7 @@ interface ImageInterface extends Traversable, Countable
|
|||||||
* @param callable $callback
|
* @param callable $callback
|
||||||
* @return ImageInterface
|
* @return ImageInterface
|
||||||
*/
|
*/
|
||||||
public function eachFrame(callable $callback): ImageInterface;
|
public function mapFrames(callable $callback): ImageInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set loop count of animated image
|
* Set loop count of animated image
|
||||||
|
Reference in New Issue
Block a user