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:
@@ -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
|
||||
*
|
||||
|
@@ -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([
|
||||
|
Reference in New Issue
Block a user