mirror of
https://github.com/Intervention/image.git
synced 2025-08-19 12:11:26 +02:00
Add missing offset calculations
This commit is contained in:
@@ -91,7 +91,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
|
||||
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 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
|
||||
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 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
|
||||
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 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
|
||||
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;
|
||||
|
||||
|
@@ -136,7 +136,7 @@ class RectangleTest extends TestCase
|
||||
$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 @@ class RectangleTest extends TestCase
|
||||
|
||||
$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 @@ class RectangleTest extends TestCase
|
||||
|
||||
$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);
|
||||
|
Reference in New Issue
Block a user