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

Add missing offset calculations

This commit is contained in:
Oliver Vogel
2023-10-21 17:40:03 +02:00
parent 00d53e24df
commit fb161a9ad3
2 changed files with 8 additions and 8 deletions

View File

@@ -91,7 +91,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
case 'top-middle': case 'top-middle':
case 'center-top': case 'center-top':
case 'middle-top': case 'middle-top':
$x = intval($this->getWidth() / 2); $x = intval($this->getWidth() / 2) + $offset_x;
$y = 0 + $offset_y; $y = 0 + $offset_y;
break; break;
@@ -107,7 +107,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
case 'center-left': case 'center-left':
case 'middle-left': case 'middle-left':
$x = 0 + $offset_x; $x = 0 + $offset_x;
$y = intval($this->getHeight() / 2); $y = intval($this->getHeight() / 2) + $offset_y;
break; break;
case 'right': case 'right':
@@ -116,7 +116,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
case 'center-right': case 'center-right':
case 'middle-right': case 'middle-right':
$x = $this->getWidth() - $offset_x; $x = $this->getWidth() - $offset_x;
$y = intval($this->getHeight() / 2); $y = intval($this->getHeight() / 2) + $offset_y;
break; break;
case 'bottom-left': case 'bottom-left':
@@ -130,7 +130,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
case 'bottom-middle': case 'bottom-middle':
case 'center-bottom': case 'center-bottom':
case 'middle-bottom': case 'middle-bottom':
$x = intval($this->getWidth() / 2); $x = intval($this->getWidth() / 2) + $offset_x;
$y = $this->getHeight() - $offset_y; $y = $this->getHeight() - $offset_y;
break; break;

View File

@@ -136,7 +136,7 @@ class RectangleTest extends TestCase
$this->assertEquals(3, $box->getPivot()->getY()); $this->assertEquals(3, $box->getPivot()->getY());
$box->movePivot('top', 3, 3); $box->movePivot('top', 3, 3);
$this->assertEquals(320, $box->getPivot()->getX()); $this->assertEquals(323, $box->getPivot()->getX());
$this->assertEquals(3, $box->getPivot()->getY()); $this->assertEquals(3, $box->getPivot()->getY());
$box->movePivot('top-right', 3, 3); $box->movePivot('top-right', 3, 3);
@@ -145,7 +145,7 @@ class RectangleTest extends TestCase
$box->movePivot('left', 3, 3); $box->movePivot('left', 3, 3);
$this->assertEquals(3, $box->getPivot()->getX()); $this->assertEquals(3, $box->getPivot()->getX());
$this->assertEquals(240, $box->getPivot()->getY()); $this->assertEquals(243, $box->getPivot()->getY());
$box->movePivot('center', 3, 3); $box->movePivot('center', 3, 3);
$this->assertEquals(323, $box->getPivot()->getX()); $this->assertEquals(323, $box->getPivot()->getX());
@@ -153,14 +153,14 @@ class RectangleTest extends TestCase
$box->movePivot('right', 3, 3); $box->movePivot('right', 3, 3);
$this->assertEquals(637, $box->getPivot()->getX()); $this->assertEquals(637, $box->getPivot()->getX());
$this->assertEquals(240, $box->getPivot()->getY()); $this->assertEquals(243, $box->getPivot()->getY());
$box->movePivot('bottom-left', 3, 3); $box->movePivot('bottom-left', 3, 3);
$this->assertEquals(3, $box->getPivot()->getX()); $this->assertEquals(3, $box->getPivot()->getX());
$this->assertEquals(477, $box->getPivot()->getY()); $this->assertEquals(477, $box->getPivot()->getY());
$box->movePivot('bottom', 3, 3); $box->movePivot('bottom', 3, 3);
$this->assertEquals(320, $box->getPivot()->getX()); $this->assertEquals(323, $box->getPivot()->getX());
$this->assertEquals(477, $box->getPivot()->getY()); $this->assertEquals(477, $box->getPivot()->getY());
$result = $box->movePivot('bottom-right', 3, 3); $result = $box->movePivot('bottom-right', 3, 3);