1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-20 04:31:24 +02:00

Rename methods

This commit is contained in:
Oliver Vogel
2023-11-22 17:07:43 +01:00
parent d7aee251ee
commit fca3da7fcd
13 changed files with 52 additions and 52 deletions

View File

@@ -14,7 +14,7 @@ class Core extends Collection implements CoreInterface
public function native() public function native()
{ {
return $this->first()->data(); return $this->first()->native();
} }
public function width(): int public function width(): int

View File

@@ -13,7 +13,7 @@ use Intervention\Image\Interfaces\SizeInterface;
class Frame implements FrameInterface class Frame implements FrameInterface
{ {
public function __construct( public function __construct(
protected GdImage $data, protected GdImage $native,
protected float $delay = 0, protected float $delay = 0,
protected int $dispose = 1, protected int $dispose = 1,
protected int $offset_left = 0, protected int $offset_left = 0,
@@ -27,26 +27,26 @@ class Frame implements FrameInterface
return new Image($driver, new Core([$this])); 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; return $this;
} }
public function data(): GdImage public function native(): GdImage
{ {
return $this->data; return $this->native;
} }
public function unsetData(): void public function unsetData(): void
{ {
unset($this->data); unset($this->native);
} }
public function size(): SizeInterface 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 public function delay(): float

View File

@@ -29,7 +29,7 @@ class CropModifier extends DriverModifier
->native(); ->native();
// get original image // get original image
$original = $frame->data(); $original = $frame->native();
// preserve transparency // preserve transparency
$transIndex = imagecolortransparent($original); $transIndex = imagecolortransparent($original);
@@ -56,6 +56,6 @@ class CropModifier extends DriverModifier
); );
// set new content as recource // set new content as recource
$frame->setData($modified); $frame->setNative($modified);
} }
} }

View File

@@ -35,7 +35,7 @@ class FillModifier extends DriverModifier
private function floodFillWithColor(Frame $frame, int $color): void private function floodFillWithColor(Frame $frame, int $color): void
{ {
imagefill( imagefill(
$frame->data(), $frame->native(),
$this->position->x(), $this->position->x(),
$this->position->y(), $this->position->y(),
$color $color
@@ -44,9 +44,9 @@ class FillModifier extends DriverModifier
private function fillAllWithColor(Frame $frame, int $color): void private function fillAllWithColor(Frame $frame, int $color): void
{ {
imagealphablending($frame->data(), true); imagealphablending($frame->native(), true);
imagefilledrectangle( imagefilledrectangle(
$frame->data(), $frame->native(),
0, 0,
0, 0,
$frame->size()->width() - 1, $frame->size()->width() - 1,

View File

@@ -30,7 +30,7 @@ class FitModifier extends DriverModifier
)->core()->native(); )->core()->native();
// get original image // get original image
$original = $frame->data(); $original = $frame->native();
// preserve transparency // preserve transparency
$transIndex = imagecolortransparent($original); $transIndex = imagecolortransparent($original);
@@ -57,6 +57,6 @@ class FitModifier extends DriverModifier
); );
// set new content as resource // set new content as resource
$frame->setData($modified); $frame->setNative($modified);
} }
} }

View File

@@ -56,7 +56,7 @@ class PadModifier extends DriverModifier
imagealphablending($modified, true); imagealphablending($modified, true);
imagecopyresampled( imagecopyresampled(
$modified, $modified,
$frame->data(), $frame->native(),
$crop->pivot()->x(), $crop->pivot()->x(),
$crop->pivot()->y(), $crop->pivot()->y(),
0, 0,
@@ -68,6 +68,6 @@ class PadModifier extends DriverModifier
); );
// set new content as recource // set new content as recource
$frame->setData($modified); $frame->setNative($modified);
} }
} }

View File

@@ -28,7 +28,7 @@ class ResizeModifier extends DriverModifier
); );
// get current GDImage // get current GDImage
$current = $frame->data(); $current = $frame->native();
// preserve transparency // preserve transparency
$transIndex = imagecolortransparent($current); $transIndex = imagecolortransparent($current);
@@ -58,7 +58,7 @@ class ResizeModifier extends DriverModifier
); );
// set new content as recource // set new content as recource
$frame->setData($modified); $frame->setNative($modified);
} }
protected function getAdjustedSize(ImageInterface $image): SizeInterface protected function getAdjustedSize(ImageInterface $image): SizeInterface

View File

@@ -42,9 +42,9 @@ class RotateModifier extends DriverModifier
protected function modifyFrame(FrameInterface $frame, ColorInterface $background): void protected function modifyFrame(FrameInterface $frame, ColorInterface $background): void
{ {
// get transparent color from frame core // get transparent color from frame core
$transparent = match ($transparent = imagecolortransparent($frame->data())) { $transparent = match ($transparent = imagecolortransparent($frame->native())) {
-1 => imagecolorallocatealpha( -1 => imagecolorallocatealpha(
$frame->data(), $frame->native(),
$background->channel(Red::class)->value(), $background->channel(Red::class)->value(),
$background->channel(Green::class)->value(), $background->channel(Green::class)->value(),
$background->channel(Blue::class)->value(), $background->channel(Blue::class)->value(),
@@ -55,7 +55,7 @@ class RotateModifier extends DriverModifier
// rotate original image against transparent background // rotate original image against transparent background
$rotated = imagerotate( $rotated = imagerotate(
$frame->data(), $frame->native(),
$this->rotationAngle(), $this->rotationAngle(),
$transparent $transparent
); );
@@ -68,8 +68,8 @@ class RotateModifier extends DriverModifier
// create size from original and rotate points // create size from original and rotate points
$cutout = (new Rectangle( $cutout = (new Rectangle(
imagesx($frame->data()), imagesx($frame->native()),
imagesy($frame->data()), imagesy($frame->native()),
$container->pivot() $container->pivot()
))->align('center') ))->align('center')
->valign('center') ->valign('center')
@@ -105,6 +105,6 @@ class RotateModifier extends DriverModifier
imagesy($rotated) imagesy($rotated)
); );
$frame->setData($modified); $frame->setNative($modified);
} }
} }

View File

@@ -16,7 +16,7 @@ class PngEncoder extends DriverEncoder
$compression = Imagick::COMPRESSION_ZIP; $compression = Imagick::COMPRESSION_ZIP;
$image = $image->modify(new LimitColorsModifier($this->color_limit)); $image = $image->modify(new LimitColorsModifier($this->color_limit));
$imagick = $image->core()->frame()->data(); $imagick = $image->core()->frame()->native();
$imagick->setFormat($format); $imagick->setFormat($format);
$imagick->setImageFormat($format); $imagick->setImageFormat($format);
$imagick->setCompression($compression); $imagick->setCompression($compression);

View File

@@ -12,64 +12,64 @@ use Intervention\Image\Interfaces\SizeInterface;
class Frame implements FrameInterface class Frame implements FrameInterface
{ {
public function __construct(protected Imagick $data) public function __construct(protected Imagick $native)
{ {
} }
public function toImage(DriverInterface $driver): ImageInterface 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; return $this;
} }
public function data(): Imagick public function native(): Imagick
{ {
return $this->data; return $this->native;
} }
public function size(): SizeInterface public function size(): SizeInterface
{ {
return new Rectangle( return new Rectangle(
$this->data->getImageWidth(), $this->native->getImageWidth(),
$this->data->getImageHeight() $this->native->getImageHeight()
); );
} }
public function delay(): float public function delay(): float
{ {
return $this->data->getImageDelay() / 100; return $this->native->getImageDelay() / 100;
} }
public function setDelay(float $delay): FrameInterface public function setDelay(float $delay): FrameInterface
{ {
$this->data->setImageDelay(intval(round($delay * 100))); $this->native->setImageDelay(intval(round($delay * 100)));
return $this; return $this;
} }
public function dispose(): int public function dispose(): int
{ {
return $this->data->getImageDispose(); return $this->native->getImageDispose();
} }
public function setDispose(int $dispose): FrameInterface public function setDispose(int $dispose): FrameInterface
{ {
$this->data->setImageDispose($dispose); $this->native->setImageDispose($dispose);
return $this; return $this;
} }
public function setOffset(int $left, int $top): FrameInterface public function setOffset(int $left, int $top): FrameInterface
{ {
$this->data->setImagePage( $this->native->setImagePage(
$this->data->getImageWidth(), $this->native->getImageWidth(),
$this->data->getImageHeight(), $this->native->getImageHeight(),
$left, $left,
$top $top
); );
@@ -79,7 +79,7 @@ class Frame implements FrameInterface
public function offsetLeft(): int public function offsetLeft(): int
{ {
return $this->data->getImagePage()['x']; return $this->native->getImagePage()['x'];
} }
public function setOffsetLeft(int $offset): FrameInterface public function setOffsetLeft(int $offset): FrameInterface
@@ -89,7 +89,7 @@ class Frame implements FrameInterface
public function offsetTop(): int public function offsetTop(): int
{ {
return $this->data->getImagePage()['y']; return $this->native->getImagePage()['y'];
} }
public function setOffsetTop(int $offset): FrameInterface public function setOffsetTop(int $offset): FrameInterface

View File

@@ -29,12 +29,12 @@ class FillModifier extends DriverModifier
private function floodFillWithColor(Frame $frame, ImagickPixel $pixel): void private function floodFillWithColor(Frame $frame, ImagickPixel $pixel): void
{ {
$target = $frame->data()->getImagePixelColor( $target = $frame->native()->getImagePixelColor(
$this->position->x(), $this->position->x(),
$this->position->y() $this->position->y()
); );
$frame->data()->floodfillPaintImage( $frame->native()->floodfillPaintImage(
$pixel, $pixel,
100, 100,
$target, $target,
@@ -52,9 +52,9 @@ class FillModifier extends DriverModifier
$draw->rectangle( $draw->rectangle(
0, 0,
0, 0,
$frame->data()->getImageWidth(), $frame->native()->getImageWidth(),
$frame->data()->getImageHeight() $frame->native()->getImageHeight()
); );
$frame->data()->drawImage($draw); $frame->native()->drawImage($draw);
} }
} }

View File

@@ -21,11 +21,11 @@ class PixelateModifier extends DriverModifier
{ {
$size = $frame->size(); $size = $frame->size();
$frame->data()->scaleImage( $frame->native()->scaleImage(
round(max(1, ($size->width() / $this->size))), round(max(1, ($size->width() / $this->size))),
round(max(1, ($size->height() / $this->size))) round(max(1, ($size->height() / $this->size)))
); );
$frame->data()->scaleImage($size->width(), $size->height()); $frame->native()->scaleImage($size->width(), $size->height());
} }
} }

View File

@@ -4,9 +4,9 @@ namespace Intervention\Image\Interfaces;
interface FrameInterface interface FrameInterface
{ {
public function data(); public function native();
public function setNative($native): FrameInterface;
public function toImage(DriverInterface $driver): ImageInterface; public function toImage(DriverInterface $driver): ImageInterface;
public function setData($data): FrameInterface;
public function size(): SizeInterface; public function size(): SizeInterface;
public function delay(): float; public function delay(): float;
public function setDelay(float $delay): FrameInterface; public function setDelay(float $delay): FrameInterface;