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

Remove unused methods from Polygon::class

- Polygon::alignPivot()
- Polygon::valignPivot()
This commit is contained in:
Oliver Vogel
2022-07-19 19:29:13 +02:00
parent 2c4a6921d8
commit 16cc19a5d0
2 changed files with 0 additions and 99 deletions

View File

@@ -254,69 +254,6 @@ class Polygon implements Countable, ArrayAccess
);
}
/**
* Align pivot point to given horizontal position
*
* @param string $position
* @return Polygon
*/
public function alignPivot(string $position): self
{
switch (strtolower($position)) {
case 'center':
$this->pivot->setX(
intval(($this->getMostRightPoint()->getX() + $this->getMostLeftPoint()->getX()) / 2)
);
break;
case 'right':
$this->pivot->setX(
$this->getMostRightPoint()->getX()
);
break;
case 'left':
$this->pivot->setX(
$this->getMostLeftPoint()->getX()
);
break;
}
return $this;
}
/**
* Align pivot point to given vertical position
*
* @param string $position
* @return Polygon
*/
public function valignPivot(string $position): self
{
switch (strtolower($position)) {
case 'center':
case 'middle':
$this->pivot->setY(
intval(($this->getMostTopPoint()->getY() + $this->getMostBottomPoint()->getY()) / 2)
);
break;
case 'top':
$this->pivot->setY(
$this->getMostTopPoint()->getY()
);
break;
case 'bottom':
$this->pivot->setY(
$this->getMostBottomPoint()->getY()
);
break;
}
return $this;
}
/**
* Align all points of polygon horizontally to given position around pivot point
*

View File

@@ -125,42 +125,6 @@ class PolygonTest extends TestCase
$this->assertInstanceOf(Point::class, $poly->getPivotPoint());
}
public function testAlignPivot(): void
{
$poly = new Polygon([
new Point(12, 45),
new Point(-24, -49),
new Point(3, 566),
]);
$this->assertEquals(0, $poly->getPivotPoint()->getX());
$this->assertEquals(0, $poly->getPivotPoint()->getY());
$result = $poly->alignPivot('center');
$this->assertInstanceOf(Polygon::class, $result);
$this->assertEquals(-6, $result->getPivotPoint()->getX());
$this->assertEquals(0, $result->getPivotPoint()->getY());
}
public function testValignPivot(): void
{
$poly = new Polygon([
new Point(12, 45),
new Point(-24, -50),
new Point(3, 566),
]);
$this->assertEquals(0, $poly->getPivotPoint()->getX());
$this->assertEquals(0, $poly->getPivotPoint()->getY());
$result = $poly->valignPivot('middle');
$this->assertInstanceOf(Polygon::class, $result);
$this->assertEquals(0, $result->getPivotPoint()->getX());
$this->assertEquals(258, $result->getPivotPoint()->getY());
}
public function testGetMostLeftPoint(): void
{
$poly = new Polygon([