1
0
mirror of https://github.com/Intervention/image.git synced 2025-03-15 22:49:40 +01:00

Rename method

- SizeInterface::getPivot to SizeInterface::pivot
This commit is contained in:
Oliver Vogel 2023-10-26 17:22:45 +02:00
parent cf2792ce45
commit fbcfab2b6c
11 changed files with 56 additions and 56 deletions

View File

@ -62,8 +62,8 @@ class CropModifier implements ModifierInterface
$current,
0,
0,
$resizeTo->getPivot()->getX() + $this->offset_x,
$resizeTo->getPivot()->getY() + $this->offset_y,
$resizeTo->pivot()->getX() + $this->offset_x,
$resizeTo->pivot()->getY() + $this->offset_y,
$resizeTo->width(),
$resizeTo->height(),
$resizeTo->width(),

View File

@ -51,8 +51,8 @@ class FitModifier extends AbstractFitModifier implements ModifierInterface
$current,
0,
0,
$crop->getPivot()->getX(),
$crop->getPivot()->getY(),
$crop->pivot()->getX(),
$crop->pivot()->getY(),
$resize->width(),
$resize->height(),
$crop->width(),

View File

@ -53,8 +53,8 @@ class PadModifier extends AbstractPadModifier implements ModifierInterface
imagecopyresampled(
$modified,
$current,
$crop->getPivot()->getX(),
$crop->getPivot()->getY(),
$crop->pivot()->getX(),
$crop->pivot()->getY(),
0,
0,
$crop->width(),

View File

@ -57,8 +57,8 @@ class ResizeModifier implements ModifierInterface
imagecopyresampled(
$modified,
$current,
$resizeTo->getPivot()->getX(),
$resizeTo->getPivot()->getY(),
$resizeTo->pivot()->getX(),
$resizeTo->pivot()->getY(),
0,
0,
$resizeTo->width(),

View File

@ -28,8 +28,8 @@ class CropModifier implements ModifierInterface
$frame->core()->extentImage(
$crop->width(),
$crop->height(),
$crop->getPivot()->getX() + $this->offset_x,
$crop->getPivot()->getY() + $this->offset_y
$crop->pivot()->getX() + $this->offset_x,
$crop->pivot()->getY() + $this->offset_y
);
}

View File

@ -17,8 +17,8 @@ class FitModifier extends AbstractFitModifier implements ModifierInterface
$frame->core()->extentImage(
$crop->width(),
$crop->height(),
$crop->getPivot()->getX(),
$crop->getPivot()->getY()
$crop->pivot()->getX(),
$crop->pivot()->getY()
);
$frame->core()->scaleImage(

View File

@ -39,8 +39,8 @@ class PadModifier extends AbstractPadModifier implements ModifierInterface
$canvas->compositeImage(
$frame->core(),
Imagick::COMPOSITE_DEFAULT,
$crop->getPivot()->getX(),
$crop->getPivot()->getY()
$crop->pivot()->getX(),
$crop->pivot()->getY()
);
// replace core
@ -71,10 +71,10 @@ class PadModifier extends AbstractPadModifier implements ModifierInterface
$fill = $background->toHex('#') == '#ff0000' ? '#00ff00' : '#ff0000';
$draw->setFillColor($fill);
$draw->rectangle(
$crop->getPivot()->getX(),
$crop->getPivot()->getY(),
$crop->getPivot()->getX() + $crop->width() - 1,
$crop->getPivot()->getY() + $crop->height() - 1
$crop->pivot()->getX(),
$crop->pivot()->getY(),
$crop->pivot()->getX() + $crop->width() - 1,
$crop->pivot()->getY() + $crop->height() - 1
);
$canvas->drawImage($draw);
$canvas->transparentPaintImage($fill, 0, 0, false);

View File

@ -62,7 +62,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
return $this;
}
public function getPivot(): Point
public function pivot(): Point
{
return $this->pivot;
}
@ -183,8 +183,8 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
public function getRelativePositionTo(SizeInterface $rectangle): PointInterface
{
return new Point(
$this->getPivot()->getX() - $rectangle->getPivot()->getX(),
$this->getPivot()->getY() - $rectangle->getPivot()->getY()
$this->pivot()->getX() - $rectangle->pivot()->getX(),
$this->pivot()->getY() - $rectangle->pivot()->getY()
);
}

View File

@ -6,7 +6,7 @@ interface SizeInterface
{
public function width(): int;
public function height(): int;
public function getPivot(): PointInterface;
public function pivot(): PointInterface;
public function setWidth(int $width): SizeInterface;
public function setHeight(int $height): SizeInterface;
public function setPivot(PointInterface $pivot): SizeInterface;

View File

@ -429,8 +429,8 @@ class RectangleResizerTest extends TestCase
$resized = $resizer->crop($origin, $position);
$this->assertEquals($result->width(), $resized->width());
$this->assertEquals($result->height(), $resized->height());
$this->assertEquals($result->getPivot()->getX(), $resized->getPivot()->getX());
$this->assertEquals($result->getPivot()->getY(), $resized->getPivot()->getY());
$this->assertEquals($result->getPivot()->getX(), $resized->pivot()->getX());
$this->assertEquals($result->getPivot()->getY(), $resized->pivot()->getY());
}
public function cropDataProvider(): array

View File

@ -117,55 +117,55 @@ class RectangleTest extends TestCase
public function testSetGetPivot(): void
{
$box = new Rectangle(800, 600);
$pivot = $box->getPivot();
$pivot = $box->pivot();
$this->assertInstanceOf(Point::class, $pivot);
$this->assertEquals(0, $pivot->getX());
$result = $box->setPivot(new Point(10, 0));
$this->assertInstanceOf(Rectangle::class, $result);
$this->assertEquals(10, $box->getPivot()->getX());
$this->assertEquals(10, $box->pivot()->getX());
}
public function testAlignPivot(): void
{
$box = new Rectangle(640, 480);
$this->assertEquals(0, $box->getPivot()->getX());
$this->assertEquals(0, $box->getPivot()->getY());
$this->assertEquals(0, $box->pivot()->getX());
$this->assertEquals(0, $box->pivot()->getY());
$box->movePivot('top-left', 3, 3);
$this->assertEquals(3, $box->getPivot()->getX());
$this->assertEquals(3, $box->getPivot()->getY());
$this->assertEquals(3, $box->pivot()->getX());
$this->assertEquals(3, $box->pivot()->getY());
$box->movePivot('top', 3, 3);
$this->assertEquals(323, $box->getPivot()->getX());
$this->assertEquals(3, $box->getPivot()->getY());
$this->assertEquals(323, $box->pivot()->getX());
$this->assertEquals(3, $box->pivot()->getY());
$box->movePivot('top-right', 3, 3);
$this->assertEquals(637, $box->getPivot()->getX());
$this->assertEquals(3, $box->getPivot()->getY());
$this->assertEquals(637, $box->pivot()->getX());
$this->assertEquals(3, $box->pivot()->getY());
$box->movePivot('left', 3, 3);
$this->assertEquals(3, $box->getPivot()->getX());
$this->assertEquals(243, $box->getPivot()->getY());
$this->assertEquals(3, $box->pivot()->getX());
$this->assertEquals(243, $box->pivot()->getY());
$box->movePivot('center', 3, 3);
$this->assertEquals(323, $box->getPivot()->getX());
$this->assertEquals(243, $box->getPivot()->getY());
$this->assertEquals(323, $box->pivot()->getX());
$this->assertEquals(243, $box->pivot()->getY());
$box->movePivot('right', 3, 3);
$this->assertEquals(637, $box->getPivot()->getX());
$this->assertEquals(243, $box->getPivot()->getY());
$this->assertEquals(637, $box->pivot()->getX());
$this->assertEquals(243, $box->pivot()->getY());
$box->movePivot('bottom-left', 3, 3);
$this->assertEquals(3, $box->getPivot()->getX());
$this->assertEquals(477, $box->getPivot()->getY());
$this->assertEquals(3, $box->pivot()->getX());
$this->assertEquals(477, $box->pivot()->getY());
$box->movePivot('bottom', 3, 3);
$this->assertEquals(323, $box->getPivot()->getX());
$this->assertEquals(477, $box->getPivot()->getY());
$this->assertEquals(323, $box->pivot()->getX());
$this->assertEquals(477, $box->pivot()->getY());
$result = $box->movePivot('bottom-right', 3, 3);
$this->assertEquals(637, $box->getPivot()->getX());
$this->assertEquals(477, $box->getPivot()->getY());
$this->assertEquals(637, $box->pivot()->getX());
$this->assertEquals(477, $box->pivot()->getY());
$this->assertInstanceOf(Rectangle::class, $result);
}
@ -175,32 +175,32 @@ class RectangleTest extends TestCase
$container = new Rectangle(800, 600);
$size = new Rectangle(200, 100);
$size->alignPivotTo($container, 'center');
$this->assertEquals(300, $size->getPivot()->getX());
$this->assertEquals(250, $size->getPivot()->getY());
$this->assertEquals(300, $size->pivot()->getX());
$this->assertEquals(250, $size->pivot()->getY());
$container = new Rectangle(800, 600);
$size = new Rectangle(100, 100);
$size->alignPivotTo($container, 'center');
$this->assertEquals(350, $size->getPivot()->getX());
$this->assertEquals(250, $size->getPivot()->getY());
$this->assertEquals(350, $size->pivot()->getX());
$this->assertEquals(250, $size->pivot()->getY());
$container = new Rectangle(800, 600);
$size = new Rectangle(800, 600);
$size->alignPivotTo($container, 'center');
$this->assertEquals(0, $size->getPivot()->getX());
$this->assertEquals(0, $size->getPivot()->getY());
$this->assertEquals(0, $size->pivot()->getX());
$this->assertEquals(0, $size->pivot()->getY());
$container = new Rectangle(100, 100);
$size = new Rectangle(800, 600);
$size->alignPivotTo($container, 'center');
$this->assertEquals(-350, $size->getPivot()->getX());
$this->assertEquals(-250, $size->getPivot()->getY());
$this->assertEquals(-350, $size->pivot()->getX());
$this->assertEquals(-250, $size->pivot()->getY());
$container = new Rectangle(100, 100);
$size = new Rectangle(800, 600);
$size->alignPivotTo($container, 'bottom-right');
$this->assertEquals(-700, $size->getPivot()->getX());
$this->assertEquals(-500, $size->getPivot()->getY());
$this->assertEquals(-700, $size->pivot()->getX());
$this->assertEquals(-500, $size->pivot()->getY());
}
public function testgetRelativePositionTo(): void