diff --git a/src/Geometry/Rectangle.php b/src/Geometry/Rectangle.php index b244a60c5..06dfaec42 100644 --- a/src/Geometry/Rectangle.php +++ b/src/Geometry/Rectangle.php @@ -91,7 +91,7 @@ public function movePivot(string $position, int $offset_x = 0, int $offset_y = 0 case 'top-middle': case 'center-top': case 'middle-top': - $x = intval($this->getWidth() / 2); + $x = intval($this->getWidth() / 2) + $offset_x; $y = 0 + $offset_y; break; @@ -107,7 +107,7 @@ public function movePivot(string $position, int $offset_x = 0, int $offset_y = 0 case 'center-left': case 'middle-left': $x = 0 + $offset_x; - $y = intval($this->getHeight() / 2); + $y = intval($this->getHeight() / 2) + $offset_y; break; case 'right': @@ -116,7 +116,7 @@ public function movePivot(string $position, int $offset_x = 0, int $offset_y = 0 case 'center-right': case 'middle-right': $x = $this->getWidth() - $offset_x; - $y = intval($this->getHeight() / 2); + $y = intval($this->getHeight() / 2) + $offset_y; break; case 'bottom-left': @@ -130,7 +130,7 @@ public function movePivot(string $position, int $offset_x = 0, int $offset_y = 0 case 'bottom-middle': case 'center-bottom': case 'middle-bottom': - $x = intval($this->getWidth() / 2); + $x = intval($this->getWidth() / 2) + $offset_x; $y = $this->getHeight() - $offset_y; break; diff --git a/tests/Geometry/RectangleTest.php b/tests/Geometry/RectangleTest.php index 7eebd9966..4ad785c80 100644 --- a/tests/Geometry/RectangleTest.php +++ b/tests/Geometry/RectangleTest.php @@ -136,7 +136,7 @@ public function testAlignPivot(): void $this->assertEquals(3, $box->getPivot()->getY()); $box->movePivot('top', 3, 3); - $this->assertEquals(320, $box->getPivot()->getX()); + $this->assertEquals(323, $box->getPivot()->getX()); $this->assertEquals(3, $box->getPivot()->getY()); $box->movePivot('top-right', 3, 3); @@ -145,7 +145,7 @@ public function testAlignPivot(): void $box->movePivot('left', 3, 3); $this->assertEquals(3, $box->getPivot()->getX()); - $this->assertEquals(240, $box->getPivot()->getY()); + $this->assertEquals(243, $box->getPivot()->getY()); $box->movePivot('center', 3, 3); $this->assertEquals(323, $box->getPivot()->getX()); @@ -153,14 +153,14 @@ public function testAlignPivot(): void $box->movePivot('right', 3, 3); $this->assertEquals(637, $box->getPivot()->getX()); - $this->assertEquals(240, $box->getPivot()->getY()); + $this->assertEquals(243, $box->getPivot()->getY()); $box->movePivot('bottom-left', 3, 3); $this->assertEquals(3, $box->getPivot()->getX()); $this->assertEquals(477, $box->getPivot()->getY()); $box->movePivot('bottom', 3, 3); - $this->assertEquals(320, $box->getPivot()->getX()); + $this->assertEquals(323, $box->getPivot()->getX()); $this->assertEquals(477, $box->getPivot()->getY()); $result = $box->movePivot('bottom-right', 3, 3);