mirror of
https://github.com/Intervention/image.git
synced 2025-08-01 11:30:16 +02:00
Rename methods
This commit is contained in:
@@ -14,7 +14,7 @@ class Core extends Collection implements CoreInterface
|
||||
|
||||
public function native()
|
||||
{
|
||||
return $this->first()->data();
|
||||
return $this->first()->native();
|
||||
}
|
||||
|
||||
public function width(): int
|
||||
|
@@ -13,7 +13,7 @@ use Intervention\Image\Interfaces\SizeInterface;
|
||||
class Frame implements FrameInterface
|
||||
{
|
||||
public function __construct(
|
||||
protected GdImage $data,
|
||||
protected GdImage $native,
|
||||
protected float $delay = 0,
|
||||
protected int $dispose = 1,
|
||||
protected int $offset_left = 0,
|
||||
@@ -27,26 +27,26 @@ class Frame implements FrameInterface
|
||||
return new Image($driver, new Core([$this]));
|
||||
}
|
||||
|
||||
public function setData($data): FrameInterface
|
||||
public function setNative($native): FrameInterface
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->native = $native;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function data(): GdImage
|
||||
public function native(): GdImage
|
||||
{
|
||||
return $this->data;
|
||||
return $this->native;
|
||||
}
|
||||
|
||||
public function unsetData(): void
|
||||
{
|
||||
unset($this->data);
|
||||
unset($this->native);
|
||||
}
|
||||
|
||||
public function size(): SizeInterface
|
||||
{
|
||||
return new Rectangle(imagesx($this->data), imagesy($this->data));
|
||||
return new Rectangle(imagesx($this->native), imagesy($this->native));
|
||||
}
|
||||
|
||||
public function delay(): float
|
||||
|
@@ -29,7 +29,7 @@ class CropModifier extends DriverModifier
|
||||
->native();
|
||||
|
||||
// get original image
|
||||
$original = $frame->data();
|
||||
$original = $frame->native();
|
||||
|
||||
// preserve transparency
|
||||
$transIndex = imagecolortransparent($original);
|
||||
@@ -56,6 +56,6 @@ class CropModifier extends DriverModifier
|
||||
);
|
||||
|
||||
// set new content as recource
|
||||
$frame->setData($modified);
|
||||
$frame->setNative($modified);
|
||||
}
|
||||
}
|
||||
|
@@ -35,7 +35,7 @@ class FillModifier extends DriverModifier
|
||||
private function floodFillWithColor(Frame $frame, int $color): void
|
||||
{
|
||||
imagefill(
|
||||
$frame->data(),
|
||||
$frame->native(),
|
||||
$this->position->x(),
|
||||
$this->position->y(),
|
||||
$color
|
||||
@@ -44,9 +44,9 @@ class FillModifier extends DriverModifier
|
||||
|
||||
private function fillAllWithColor(Frame $frame, int $color): void
|
||||
{
|
||||
imagealphablending($frame->data(), true);
|
||||
imagealphablending($frame->native(), true);
|
||||
imagefilledrectangle(
|
||||
$frame->data(),
|
||||
$frame->native(),
|
||||
0,
|
||||
0,
|
||||
$frame->size()->width() - 1,
|
||||
|
@@ -30,7 +30,7 @@ class FitModifier extends DriverModifier
|
||||
)->core()->native();
|
||||
|
||||
// get original image
|
||||
$original = $frame->data();
|
||||
$original = $frame->native();
|
||||
|
||||
// preserve transparency
|
||||
$transIndex = imagecolortransparent($original);
|
||||
@@ -57,6 +57,6 @@ class FitModifier extends DriverModifier
|
||||
);
|
||||
|
||||
// set new content as resource
|
||||
$frame->setData($modified);
|
||||
$frame->setNative($modified);
|
||||
}
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ class PadModifier extends DriverModifier
|
||||
imagealphablending($modified, true);
|
||||
imagecopyresampled(
|
||||
$modified,
|
||||
$frame->data(),
|
||||
$frame->native(),
|
||||
$crop->pivot()->x(),
|
||||
$crop->pivot()->y(),
|
||||
0,
|
||||
@@ -68,6 +68,6 @@ class PadModifier extends DriverModifier
|
||||
);
|
||||
|
||||
// set new content as recource
|
||||
$frame->setData($modified);
|
||||
$frame->setNative($modified);
|
||||
}
|
||||
}
|
||||
|
@@ -28,7 +28,7 @@ class ResizeModifier extends DriverModifier
|
||||
);
|
||||
|
||||
// get current GDImage
|
||||
$current = $frame->data();
|
||||
$current = $frame->native();
|
||||
|
||||
// preserve transparency
|
||||
$transIndex = imagecolortransparent($current);
|
||||
@@ -58,7 +58,7 @@ class ResizeModifier extends DriverModifier
|
||||
);
|
||||
|
||||
// set new content as recource
|
||||
$frame->setData($modified);
|
||||
$frame->setNative($modified);
|
||||
}
|
||||
|
||||
protected function getAdjustedSize(ImageInterface $image): SizeInterface
|
||||
|
@@ -42,9 +42,9 @@ class RotateModifier extends DriverModifier
|
||||
protected function modifyFrame(FrameInterface $frame, ColorInterface $background): void
|
||||
{
|
||||
// get transparent color from frame core
|
||||
$transparent = match ($transparent = imagecolortransparent($frame->data())) {
|
||||
$transparent = match ($transparent = imagecolortransparent($frame->native())) {
|
||||
-1 => imagecolorallocatealpha(
|
||||
$frame->data(),
|
||||
$frame->native(),
|
||||
$background->channel(Red::class)->value(),
|
||||
$background->channel(Green::class)->value(),
|
||||
$background->channel(Blue::class)->value(),
|
||||
@@ -55,7 +55,7 @@ class RotateModifier extends DriverModifier
|
||||
|
||||
// rotate original image against transparent background
|
||||
$rotated = imagerotate(
|
||||
$frame->data(),
|
||||
$frame->native(),
|
||||
$this->rotationAngle(),
|
||||
$transparent
|
||||
);
|
||||
@@ -68,8 +68,8 @@ class RotateModifier extends DriverModifier
|
||||
|
||||
// create size from original and rotate points
|
||||
$cutout = (new Rectangle(
|
||||
imagesx($frame->data()),
|
||||
imagesy($frame->data()),
|
||||
imagesx($frame->native()),
|
||||
imagesy($frame->native()),
|
||||
$container->pivot()
|
||||
))->align('center')
|
||||
->valign('center')
|
||||
@@ -105,6 +105,6 @@ class RotateModifier extends DriverModifier
|
||||
imagesy($rotated)
|
||||
);
|
||||
|
||||
$frame->setData($modified);
|
||||
$frame->setNative($modified);
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ class PngEncoder extends DriverEncoder
|
||||
$compression = Imagick::COMPRESSION_ZIP;
|
||||
|
||||
$image = $image->modify(new LimitColorsModifier($this->color_limit));
|
||||
$imagick = $image->core()->frame()->data();
|
||||
$imagick = $image->core()->frame()->native();
|
||||
$imagick->setFormat($format);
|
||||
$imagick->setImageFormat($format);
|
||||
$imagick->setCompression($compression);
|
||||
|
@@ -12,64 +12,64 @@ use Intervention\Image\Interfaces\SizeInterface;
|
||||
|
||||
class Frame implements FrameInterface
|
||||
{
|
||||
public function __construct(protected Imagick $data)
|
||||
public function __construct(protected Imagick $native)
|
||||
{
|
||||
}
|
||||
|
||||
public function toImage(DriverInterface $driver): ImageInterface
|
||||
{
|
||||
return new Image($driver, new Core($this->data()));
|
||||
return new Image($driver, new Core($this->native()));
|
||||
}
|
||||
|
||||
public function setData($data): FrameInterface
|
||||
public function setNative($native): FrameInterface
|
||||
{
|
||||
$this->data = $data;
|
||||
$this->native = $native;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function data(): Imagick
|
||||
public function native(): Imagick
|
||||
{
|
||||
return $this->data;
|
||||
return $this->native;
|
||||
}
|
||||
|
||||
public function size(): SizeInterface
|
||||
{
|
||||
return new Rectangle(
|
||||
$this->data->getImageWidth(),
|
||||
$this->data->getImageHeight()
|
||||
$this->native->getImageWidth(),
|
||||
$this->native->getImageHeight()
|
||||
);
|
||||
}
|
||||
|
||||
public function delay(): float
|
||||
{
|
||||
return $this->data->getImageDelay() / 100;
|
||||
return $this->native->getImageDelay() / 100;
|
||||
}
|
||||
|
||||
public function setDelay(float $delay): FrameInterface
|
||||
{
|
||||
$this->data->setImageDelay(intval(round($delay * 100)));
|
||||
$this->native->setImageDelay(intval(round($delay * 100)));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function dispose(): int
|
||||
{
|
||||
return $this->data->getImageDispose();
|
||||
return $this->native->getImageDispose();
|
||||
}
|
||||
|
||||
public function setDispose(int $dispose): FrameInterface
|
||||
{
|
||||
$this->data->setImageDispose($dispose);
|
||||
$this->native->setImageDispose($dispose);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setOffset(int $left, int $top): FrameInterface
|
||||
{
|
||||
$this->data->setImagePage(
|
||||
$this->data->getImageWidth(),
|
||||
$this->data->getImageHeight(),
|
||||
$this->native->setImagePage(
|
||||
$this->native->getImageWidth(),
|
||||
$this->native->getImageHeight(),
|
||||
$left,
|
||||
$top
|
||||
);
|
||||
@@ -79,7 +79,7 @@ class Frame implements FrameInterface
|
||||
|
||||
public function offsetLeft(): int
|
||||
{
|
||||
return $this->data->getImagePage()['x'];
|
||||
return $this->native->getImagePage()['x'];
|
||||
}
|
||||
|
||||
public function setOffsetLeft(int $offset): FrameInterface
|
||||
@@ -89,7 +89,7 @@ class Frame implements FrameInterface
|
||||
|
||||
public function offsetTop(): int
|
||||
{
|
||||
return $this->data->getImagePage()['y'];
|
||||
return $this->native->getImagePage()['y'];
|
||||
}
|
||||
|
||||
public function setOffsetTop(int $offset): FrameInterface
|
||||
|
@@ -29,12 +29,12 @@ class FillModifier extends DriverModifier
|
||||
|
||||
private function floodFillWithColor(Frame $frame, ImagickPixel $pixel): void
|
||||
{
|
||||
$target = $frame->data()->getImagePixelColor(
|
||||
$target = $frame->native()->getImagePixelColor(
|
||||
$this->position->x(),
|
||||
$this->position->y()
|
||||
);
|
||||
|
||||
$frame->data()->floodfillPaintImage(
|
||||
$frame->native()->floodfillPaintImage(
|
||||
$pixel,
|
||||
100,
|
||||
$target,
|
||||
@@ -52,9 +52,9 @@ class FillModifier extends DriverModifier
|
||||
$draw->rectangle(
|
||||
0,
|
||||
0,
|
||||
$frame->data()->getImageWidth(),
|
||||
$frame->data()->getImageHeight()
|
||||
$frame->native()->getImageWidth(),
|
||||
$frame->native()->getImageHeight()
|
||||
);
|
||||
$frame->data()->drawImage($draw);
|
||||
$frame->native()->drawImage($draw);
|
||||
}
|
||||
}
|
||||
|
@@ -21,11 +21,11 @@ class PixelateModifier extends DriverModifier
|
||||
{
|
||||
$size = $frame->size();
|
||||
|
||||
$frame->data()->scaleImage(
|
||||
$frame->native()->scaleImage(
|
||||
round(max(1, ($size->width() / $this->size))),
|
||||
round(max(1, ($size->height() / $this->size)))
|
||||
);
|
||||
|
||||
$frame->data()->scaleImage($size->width(), $size->height());
|
||||
$frame->native()->scaleImage($size->width(), $size->height());
|
||||
}
|
||||
}
|
||||
|
@@ -4,9 +4,9 @@ namespace Intervention\Image\Interfaces;
|
||||
|
||||
interface FrameInterface
|
||||
{
|
||||
public function data();
|
||||
public function native();
|
||||
public function setNative($native): FrameInterface;
|
||||
public function toImage(DriverInterface $driver): ImageInterface;
|
||||
public function setData($data): FrameInterface;
|
||||
public function size(): SizeInterface;
|
||||
public function delay(): float;
|
||||
public function setDelay(float $delay): FrameInterface;
|
||||
|
Reference in New Issue
Block a user