1
0
mirror of https://github.com/Intervention/image.git synced 2025-01-17 12:18:14 +01:00

Rename methods

SizeInterface::getWidth to SizeInterface::width
SizeInterface::getHeight to SizeInterface::height
This commit is contained in:
Oliver Vogel 2023-10-24 20:07:30 +02:00
parent 9150e4bfa3
commit 826fd22f4f
28 changed files with 211 additions and 211 deletions

View File

@ -116,11 +116,11 @@ abstract class AbstractFont implements FontInterface
public function capHeight(): int
{
return $this->getBoxSize('T')->getHeight();
return $this->getBoxSize('T')->height();
}
public function fontSizeInPixels(): int
{
return $this->getBoxSize('Hy')->getHeight();
return $this->getBoxSize('Hy')->height();
}
}

View File

@ -22,8 +22,8 @@ abstract class AbstractFitModifier
$crop = new Rectangle($this->width, $this->height);
$crop = $crop->contain(
$imagesize->getWidth(),
$imagesize->getHeight()
$imagesize->width(),
$imagesize->height()
)->alignPivotTo($imagesize, $this->position);
return $crop;

View File

@ -37,8 +37,8 @@ class CropModifier implements ModifierInterface
{
// create new image
$modified = imagecreatetruecolor(
$resizeTo->getWidth(),
$resizeTo->getHeight()
$resizeTo->width(),
$resizeTo->height()
);
// get current image
@ -64,18 +64,18 @@ class CropModifier implements ModifierInterface
0,
$resizeTo->getPivot()->getX() + $this->offset_x,
$resizeTo->getPivot()->getY() + $this->offset_y,
$resizeTo->getWidth(),
$resizeTo->getHeight(),
$resizeTo->getWidth(),
$resizeTo->getHeight(),
$resizeTo->width(),
$resizeTo->height(),
$resizeTo->width(),
$resizeTo->height(),
);
imagedestroy($current);
if ($transIndex != -1) { // @todo refactor because of duplication
imagecolortransparent($modified, $transIndex);
for ($y = 0; $y < $resizeTo->getHeight(); ++$y) {
for ($x = 0; $x < $resizeTo->getWidth(); ++$x) {
for ($y = 0; $y < $resizeTo->height(); ++$y) {
for ($x = 0; $x < $resizeTo->width(); ++$x) {
if (((imagecolorat($modified, $x, $y) >> 24) & 0x7F) >= 100) {
imagesetpixel(
$modified,

View File

@ -50,8 +50,8 @@ class FillModifier implements ModifierInterface
$frame->getCore(),
0,
0,
$frame->getSize()->getWidth() - 1,
$frame->getSize()->getHeight() - 1,
$frame->getSize()->width() - 1,
$frame->getSize()->height() - 1,
$color
);
}

View File

@ -26,8 +26,8 @@ class FitModifier extends AbstractFitModifier implements ModifierInterface
{
// create new image
$modified = imagecreatetruecolor(
$resize->getWidth(),
$resize->getHeight()
$resize->width(),
$resize->height()
);
// get current image
@ -53,18 +53,18 @@ class FitModifier extends AbstractFitModifier implements ModifierInterface
0,
$crop->getPivot()->getX(),
$crop->getPivot()->getY(),
$resize->getWidth(),
$resize->getHeight(),
$crop->getWidth(),
$crop->getHeight()
$resize->width(),
$resize->height(),
$crop->width(),
$crop->height()
);
imagedestroy($current);
if ($transIndex != -1) { // @todo refactor because of duplication
imagecolortransparent($modified, $transIndex);
for ($y = 0; $y < $resize->getHeight(); ++$y) {
for ($x = 0; $x < $resize->getWidth(); ++$x) {
for ($y = 0; $y < $resize->height(); ++$y) {
for ($x = 0; $x < $resize->width(); ++$x) {
if (((imagecolorat($modified, $x, $y) >> 24) & 0x7F) >= 100) {
imagesetpixel(
$modified,

View File

@ -13,7 +13,7 @@ class PadDownModifier extends PadModifier
$resize = $this->getResizeSize($image);
return $image->size()
->contain($resize->getWidth(), $resize->getHeight())
->contain($resize->width(), $resize->height())
->alignPivotTo($resize, $this->position);
}

View File

@ -36,8 +36,8 @@ class PadModifier extends AbstractPadModifier implements ModifierInterface
): void {
// create new image
$modified = imagecreatetruecolor(
$resize->getWidth(),
$resize->getHeight()
$resize->width(),
$resize->height()
);
imagefill($modified, 0, 0, $background);
@ -57,10 +57,10 @@ class PadModifier extends AbstractPadModifier implements ModifierInterface
$crop->getPivot()->getY(),
0,
0,
$crop->getWidth(),
$crop->getHeight(),
$frame->getSize()->getWidth(),
$frame->getSize()->getHeight()
$crop->width(),
$crop->height(),
$frame->getSize()->width(),
$frame->getSize()->height()
);
imagedestroy($current);

View File

@ -34,8 +34,8 @@ class ResizeModifier implements ModifierInterface
{
// create new image
$modified = imagecreatetruecolor(
$resizeTo->getWidth(),
$resizeTo->getHeight()
$resizeTo->width(),
$resizeTo->height()
);
// get current image
@ -61,18 +61,18 @@ class ResizeModifier implements ModifierInterface
$resizeTo->getPivot()->getY(),
0,
0,
$resizeTo->getWidth(),
$resizeTo->getHeight(),
$frame->getSize()->getWidth(),
$frame->getSize()->getHeight()
$resizeTo->width(),
$resizeTo->height(),
$frame->getSize()->width(),
$frame->getSize()->height()
);
imagedestroy($current);
if ($transIndex != -1) { // @todo refactor because of duplication
imagecolortransparent($modified, $transIndex);
for ($y = 0; $y < $resizeTo->getHeight(); ++$y) {
for ($x = 0; $x < $resizeTo->getWidth(); ++$x) {
for ($y = 0; $y < $resizeTo->height(); ++$y) {
for ($x = 0; $x < $resizeTo->width(); ++$x) {
if (((imagecolorat($modified, $x, $y) >> 24) & 0x7F) >= 100) {
imagesetpixel(
$modified,

View File

@ -55,8 +55,8 @@ class Image extends AbstractImage implements ImageInterface, Iterator
$size = $frame->getSize();
$imagick->setImagePage(
$size->getWidth(),
$size->getHeight(),
$size->width(),
$size->height(),
$frame->getOffsetLeft(),
$frame->getOffsetTop()
);

View File

@ -26,8 +26,8 @@ class CropModifier implements ModifierInterface
foreach ($image as $frame) {
$frame->getCore()->extentImage(
$crop->getWidth(),
$crop->getHeight(),
$crop->width(),
$crop->height(),
$crop->getPivot()->getX() + $this->offset_x,
$crop->getPivot()->getY() + $this->offset_y
);

View File

@ -15,15 +15,15 @@ class FitModifier extends AbstractFitModifier implements ModifierInterface
foreach ($image as $frame) {
$frame->getCore()->extentImage(
$crop->getWidth(),
$crop->getHeight(),
$crop->width(),
$crop->height(),
$crop->getPivot()->getX(),
$crop->getPivot()->getY()
);
$frame->getCore()->scaleImage(
$resize->getWidth(),
$resize->getHeight()
$resize->width(),
$resize->height()
);
}

View File

@ -13,7 +13,7 @@ class PadDownModifier extends PadModifier
$resize = $this->getResizeSize($image);
return $image->size()
->contain($resize->getWidth(), $resize->getHeight())
->contain($resize->width(), $resize->height())
->alignPivotTo($resize, $this->position);
}

View File

@ -28,8 +28,8 @@ class PadModifier extends AbstractPadModifier implements ModifierInterface
foreach ($image as $frame) {
// resize current core
$frame->getCore()->scaleImage(
$crop->getWidth(),
$crop->getHeight()
$crop->width(),
$crop->height()
);
// create new canvas, to get newly emerged background color
@ -55,8 +55,8 @@ class PadModifier extends AbstractPadModifier implements ModifierInterface
{
// build base canvas in target size
$canvas = $this->imageFactory()->newCore(
$resize->getWidth(),
$resize->getHeight()
$resize->width(),
$resize->height()
);
// draw background color on canvas
@ -73,8 +73,8 @@ class PadModifier extends AbstractPadModifier implements ModifierInterface
$draw->rectangle(
$crop->getPivot()->getX(),
$crop->getPivot()->getY(),
$crop->getPivot()->getX() + $crop->getWidth() - 1,
$crop->getPivot()->getY() + $crop->getHeight() - 1
$crop->getPivot()->getX() + $crop->width() - 1,
$crop->getPivot()->getY() + $crop->height() - 1
);
$canvas->drawImage($draw);
$canvas->transparentPaintImage($fill, 0, 0, false);

View File

@ -27,10 +27,10 @@ class PixelateModifier implements ModifierInterface
$size = $frame->getSize();
$frame->getCore()->scaleImage(
round(max(1, ($size->getWidth() / $this->size))),
round(max(1, ($size->getHeight() / $this->size)))
round(max(1, ($size->width() / $this->size))),
round(max(1, ($size->height() / $this->size)))
);
$frame->getCore()->scaleImage($size->getWidth(), $size->getHeight());
$frame->getCore()->scaleImage($size->width(), $size->height());
}
}

View File

@ -19,8 +19,8 @@ class ResizeModifier implements ModifierInterface
foreach ($image as $frame) {
$frame->getCore()->scaleImage(
$resizeTo->getWidth(),
$resizeTo->getHeight()
$resizeTo->width(),
$resizeTo->height()
);
}

View File

@ -159,7 +159,7 @@ class Polygon implements IteratorAggregate, Countable, ArrayAccess, DrawableInte
*
* @return int
*/
public function getWidth(): int
public function width(): int
{
return abs($this->getMostLeftPoint()->getX() - $this->getMostRightPoint()->getX());
}
@ -169,7 +169,7 @@ class Polygon implements IteratorAggregate, Countable, ArrayAccess, DrawableInte
*
* @return int
*/
public function getHeight(): int
public function height(): int
{
return abs($this->getMostBottomPoint()->getY() - $this->getMostTopPoint()->getY());
}
@ -270,8 +270,8 @@ class Polygon implements IteratorAggregate, Countable, ArrayAccess, DrawableInte
public function getCenterPoint(): Point
{
return new Point(
$this->getMostRightPoint()->getX() - (intval(round($this->getWidth() / 2))),
$this->getMostTopPoint()->getY() - (intval(round($this->getHeight() / 2)))
$this->getMostRightPoint()->getX() - (intval(round($this->width() / 2))),
$this->getMostTopPoint()->getY() - (intval(round($this->height() / 2)))
);
}
@ -323,12 +323,12 @@ class Polygon implements IteratorAggregate, Countable, ArrayAccess, DrawableInte
break;
case 'top':
$diff = ($this->getMostTopPoint()->getY() - $this->getPivot()->getY()) - $this->getHeight();
$diff = ($this->getMostTopPoint()->getY() - $this->getPivot()->getY()) - $this->height();
break;
default:
case 'bottom':
$diff = ($this->getMostBottomPoint()->getY() - $this->getPivot()->getY()) + $this->getHeight();
$diff = ($this->getMostBottomPoint()->getY() - $this->getPivot()->getY()) + $this->height();
break;
}

View File

@ -91,13 +91,13 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
case 'top-middle':
case 'center-top':
case 'middle-top':
$x = intval($this->getWidth() / 2) + $offset_x;
$x = intval($this->width() / 2) + $offset_x;
$y = 0 + $offset_y;
break;
case 'top-right':
case 'right-top':
$x = $this->getWidth() - $offset_x;
$x = $this->width() - $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) + $offset_y;
$y = intval($this->height() / 2) + $offset_y;
break;
case 'right':
@ -115,14 +115,14 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
case 'right-middle':
case 'center-right':
case 'middle-right':
$x = $this->getWidth() - $offset_x;
$y = intval($this->getHeight() / 2) + $offset_y;
$x = $this->width() - $offset_x;
$y = intval($this->height() / 2) + $offset_y;
break;
case 'bottom-left':
case 'left-bottom':
$x = 0 + $offset_x;
$y = $this->getHeight() - $offset_y;
$y = $this->height() - $offset_y;
break;
case 'bottom':
@ -130,22 +130,22 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
case 'bottom-middle':
case 'center-bottom':
case 'middle-bottom':
$x = intval($this->getWidth() / 2) + $offset_x;
$y = $this->getHeight() - $offset_y;
$x = intval($this->width() / 2) + $offset_x;
$y = $this->height() - $offset_y;
break;
case 'bottom-right':
case 'right-bottom':
$x = $this->getWidth() - $offset_x;
$y = $this->getHeight() - $offset_y;
$x = $this->width() - $offset_x;
$y = $this->height() - $offset_y;
break;
case 'center':
case 'middle':
case 'center-center':
case 'middle-middle':
$x = intval($this->getWidth() / 2) + $offset_x;
$y = intval($this->getHeight() / 2) + $offset_y;
$x = intval($this->width() / 2) + $offset_x;
$y = intval($this->height() / 2) + $offset_y;
break;
default:
@ -163,7 +163,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
public function alignPivotTo(SizeInterface $size, string $position): self
{
$reference = new self($size->getWidth(), $size->getHeight());
$reference = new self($size->width(), $size->height());
$reference->movePivot($position);
$this->movePivot($position)->setPivot(
@ -190,16 +190,16 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
public function getAspectRatio(): float
{
return $this->getWidth() / $this->getHeight();
return $this->width() / $this->height();
}
public function fitsInto(SizeInterface $size): bool
{
if ($this->getWidth() > $size->getWidth()) {
if ($this->width() > $size->width()) {
return false;
}
if ($this->getHeight() > $size->getHeight()) {
if ($this->height() > $size->height()) {
return false;
}
@ -213,7 +213,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
*/
public function isLandscape(): bool
{
return $this->getWidth() > $this->getHeight();
return $this->width() > $this->height();
}
/**
@ -223,7 +223,7 @@ class Rectangle extends Polygon implements SizeInterface, DrawableInterface
*/
public function isPortrait(): bool
{
return $this->getWidth() < $this->getHeight();
return $this->width() < $this->height();
}
public function topLeftPoint(): PointInterface

View File

@ -65,8 +65,8 @@ class RectangleResizer
public function toSize(SizeInterface $size): self
{
$this->width = $size->getWidth();
$this->height = $size->getHeight();
$this->width = $size->width();
$this->height = $size->height();
return $this;
}
@ -74,7 +74,7 @@ class RectangleResizer
protected function getProportionalWidth(SizeInterface $size): int
{
if (! $this->hasTargetHeight()) {
return $size->getWidth();
return $size->width();
}
return (int) round($this->height * $size->getAspectRatio());
@ -83,7 +83,7 @@ class RectangleResizer
protected function getProportionalHeight(SizeInterface $size): int
{
if (! $this->hasTargetWidth()) {
return $size->getHeight();
return $size->height();
}
return (int) round($this->width / $size->getAspectRatio());
@ -91,7 +91,7 @@ class RectangleResizer
public function resize(SizeInterface $size): SizeInterface
{
$resized = new Rectangle($size->getWidth(), $size->getHeight());
$resized = new Rectangle($size->width(), $size->height());
if ($width = $this->getTargetWidth()) {
$resized->setWidth($width);
@ -106,17 +106,17 @@ class RectangleResizer
public function resizeDown(SizeInterface $size): SizeInterface
{
$resized = new Rectangle($size->getWidth(), $size->getHeight());
$resized = new Rectangle($size->width(), $size->height());
if ($width = $this->getTargetWidth()) {
$resized->setWidth(
min($width, $size->getWidth())
min($width, $size->width())
);
}
if ($height = $this->getTargetHeight()) {
$resized->setHeight(
min($height, $size->getHeight())
min($height, $size->height())
);
}
@ -125,7 +125,7 @@ class RectangleResizer
public function scale(SizeInterface $size): SizeInterface
{
$resized = new Rectangle($size->getWidth(), $size->getHeight());
$resized = new Rectangle($size->width(), $size->height());
if ($this->hasTargetWidth() && $this->hasTargetHeight()) {
$resized->setWidth(min(
@ -149,36 +149,36 @@ class RectangleResizer
public function scaleDown(SizeInterface $size): SizeInterface
{
$resized = new Rectangle($size->getWidth(), $size->getHeight());
$resized = new Rectangle($size->width(), $size->height());
if ($this->hasTargetWidth() && $this->hasTargetHeight()) {
$resized->setWidth(min(
$this->getProportionalWidth($size),
$this->getTargetWidth(),
$size->getWidth()
$size->width()
));
$resized->setHeight(min(
$this->getProportionalHeight($size),
$this->getTargetHeight(),
$size->getHeight()
$size->height()
));
} elseif ($this->hasTargetWidth()) {
$resized->setWidth(min(
$this->getTargetWidth(),
$size->getWidth()
$size->width()
));
$resized->setHeight(min(
$this->getProportionalHeight($size),
$size->getHeight()
$size->height()
));
} elseif ($this->hasTargetHeight()) {
$resized->setWidth(min(
$this->getProportionalWidth($size),
$size->getWidth()
$size->width()
));
$resized->setHeight(min(
$this->getTargetHeight(),
$size->getHeight()
$size->height()
));
}
@ -193,7 +193,7 @@ class RectangleResizer
*/
public function cover(SizeInterface $size): SizeInterface
{
$resized = new Rectangle($size->getWidth(), $size->getHeight());
$resized = new Rectangle($size->width(), $size->height());
// auto height
$resized->setWidth($this->getTargetWidth());
@ -216,7 +216,7 @@ class RectangleResizer
*/
public function contain(SizeInterface $size): SizeInterface
{
$resized = new Rectangle($size->getWidth(), $size->getHeight());
$resized = new Rectangle($size->width(), $size->height());
// auto height
$resized->setWidth($this->getTargetWidth());

View File

@ -4,8 +4,8 @@ namespace Intervention\Image\Interfaces;
interface SizeInterface
{
public function getWidth(): int;
public function getHeight(): int;
public function width(): int;
public function height(): int;
public function getPivot(): PointInterface;
public function setWidth(int $width): SizeInterface;
public function setHeight(int $height): SizeInterface;

View File

@ -28,7 +28,7 @@ class Line
public function widthInFont(FontInterface $font): int
{
return $font->getBoxSize($this->text)->getWidth();
return $font->getBoxSize($this->text)->width();
}
public function __toString(): string

View File

@ -45,16 +45,16 @@ class AbstractImageTest extends TestCase
{
$img = $this->abstractImageMock();
$this->assertInstanceOf(Rectangle::class, $img->size());
$this->assertEquals(300, $img->size()->getWidth());
$this->assertEquals(200, $img->size()->getHeight());
$this->assertEquals(300, $img->size()->width());
$this->assertEquals(200, $img->size()->height());
}
public function testSizeAlias(): void
{
$img = $this->abstractImageMock();
$this->assertInstanceOf(Rectangle::class, $img->size());
$this->assertEquals(300, $img->size()->getWidth());
$this->assertEquals(200, $img->size()->getHeight());
$this->assertEquals(300, $img->size()->width());
$this->assertEquals(200, $img->size()->height());
}
public function testModify(): void

View File

@ -29,8 +29,8 @@ class AbstractFitModifierTest extends TestCase
$image = (new ImageFactory())->newImage($width, $height);
$size = $modifier->getCropSize($image);
static::assertSame($expectedWidth, $size->getWidth());
static::assertSame($expectedHeight, $size->getHeight());
static::assertSame($expectedWidth, $size->width());
static::assertSame($expectedHeight, $size->height());
static::assertSame($expectedX, $size->getPivot()->getX());
static::assertSame($expectedY, $size->getPivot()->getY());
}
@ -43,8 +43,8 @@ class AbstractFitModifierTest extends TestCase
$size = $modifier->getCropSize($image);
$resize = $modifier->getResizeSize($size);
static::assertSame(200, $resize->getWidth());
static::assertSame(100, $resize->getHeight());
static::assertSame(200, $resize->width());
static::assertSame(100, $resize->height());
static::assertSame(0, $resize->getPivot()->getX());
static::assertSame(0, $resize->getPivot()->getY());
}

View File

@ -31,8 +31,8 @@ final class AbstractPadModifierTest extends TestCase
$image = (new ImageFactory())->newImage($width, $height);
$size = $modifier->getCropSize($image);
static::assertSame($expectedWidth, $size->getWidth());
static::assertSame($expectedHeight, $size->getHeight());
static::assertSame($expectedWidth, $size->width());
static::assertSame($expectedHeight, $size->height());
static::assertSame($expectedX, $size->getPivot()->getX());
static::assertSame($expectedY, $size->getPivot()->getY());
}
@ -44,8 +44,8 @@ final class AbstractPadModifierTest extends TestCase
$image = (new ImageFactory())->newImage(300, 200);
$resize = $modifier->getResizeSize($image);
static::assertSame(200, $resize->getWidth());
static::assertSame(100, $resize->getHeight());
static::assertSame(200, $resize->width());
static::assertSame(100, $resize->height());
static::assertSame(0, $resize->getPivot()->getX());
static::assertSame(0, $resize->getPivot()->getY());
}

View File

@ -36,10 +36,10 @@ class FrameTest extends TestCase
$core1 = imagecreatetruecolor(3, 2);
$core2 = imagecreatetruecolor(3, 3);
$frame = new Frame($core1);
$this->assertEquals(2, $frame->getSize()->getHeight());
$this->assertEquals(2, $frame->getSize()->height());
$result = $frame->setCore($core2);
$this->assertInstanceOf(Frame::class, $result);
$this->assertEquals(3, $frame->getSize()->getHeight());
$this->assertEquals(3, $frame->getSize()->height());
}
public function testGetSize(): void

View File

@ -72,7 +72,7 @@ class PolygonTest extends TestCase
new Point(3, 566),
]);
$this->assertEquals($poly->getWidth(), 35);
$this->assertEquals($poly->width(), 35);
}
public function testGetHeight(): void
@ -83,7 +83,7 @@ class PolygonTest extends TestCase
new Point(3, 566),
]);
$this->assertEquals(615, $poly->getHeight());
$this->assertEquals(615, $poly->height());
$poly = new Polygon([
new Point(250, 207),
@ -92,7 +92,7 @@ class PolygonTest extends TestCase
new Point(250, 250),
], new Point(250, 250));
$this->assertEquals(43, $poly->getHeight());
$this->assertEquals(43, $poly->height());
}
public function testFirst(): void

View File

@ -54,28 +54,28 @@ class RectangleResizerTest extends TestCase
$resizer = new RectangleResizer();
$resizer->toWidth(150);
$result = $resizer->resize($size);
$this->assertEquals(150, $result->getWidth());
$this->assertEquals(200, $result->getHeight());
$this->assertEquals(150, $result->width());
$this->assertEquals(200, $result->height());
$size = new Rectangle(300, 200);
$resizer = new RectangleResizer();
$resizer->toWidth(20);
$resizer->toHeight(10);
$result = $resizer->resize($size);
$this->assertEquals(20, $result->getWidth());
$this->assertEquals(10, $result->getHeight());
$this->assertEquals(20, $result->width());
$this->assertEquals(10, $result->height());
$size = new Rectangle(300, 200);
$resizer = new RectangleResizer(width: 150);
$result = $resizer->resize($size);
$this->assertEquals(150, $result->getWidth());
$this->assertEquals(200, $result->getHeight());
$this->assertEquals(150, $result->width());
$this->assertEquals(200, $result->height());
$size = new Rectangle(300, 200);
$resizer = new RectangleResizer(height: 10, width: 20);
$result = $resizer->resize($size);
$this->assertEquals(20, $result->getWidth());
$this->assertEquals(10, $result->getHeight());
$this->assertEquals(20, $result->width());
$this->assertEquals(10, $result->height());
}
public function testResizeDown()
@ -86,8 +86,8 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(1000);
$resizer->toHeight(2000);
$result = $resizer->resizeDown($size);
$this->assertEquals(800, $result->getWidth());
$this->assertEquals(600, $result->getHeight());
$this->assertEquals(800, $result->width());
$this->assertEquals(600, $result->height());
// 800x600 > 400x1000 = 400x600
$size = new Rectangle(800, 600);
@ -95,8 +95,8 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(400);
$resizer->toHeight(1000);
$result = $resizer->resizeDown($size);
$this->assertEquals(400, $result->getWidth());
$this->assertEquals(600, $result->getHeight());
$this->assertEquals(400, $result->width());
$this->assertEquals(600, $result->height());
// 800x600 > 1000x400 = 800x400
$size = new Rectangle(800, 600);
@ -104,8 +104,8 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(1000);
$resizer->toHeight(400);
$result = $resizer->resizeDown($size);
$this->assertEquals(800, $result->getWidth());
$this->assertEquals(400, $result->getHeight());
$this->assertEquals(800, $result->width());
$this->assertEquals(400, $result->height());
// 800x600 > 400x300 = 400x300
$size = new Rectangle(800, 600);
@ -113,24 +113,24 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(400);
$resizer->toHeight(300);
$result = $resizer->resizeDown($size);
$this->assertEquals(400, $result->getWidth());
$this->assertEquals(300, $result->getHeight());
$this->assertEquals(400, $result->width());
$this->assertEquals(300, $result->height());
// 800x600 > 1000xnull = 800x600
$size = new Rectangle(800, 600);
$resizer = new RectangleResizer();
$resizer->toWidth(1000);
$result = $resizer->resizeDown($size);
$this->assertEquals(800, $result->getWidth());
$this->assertEquals(600, $result->getHeight());
$this->assertEquals(800, $result->width());
$this->assertEquals(600, $result->height());
// 800x600 > nullx1000 = 800x600
$size = new Rectangle(800, 600);
$resizer = new RectangleResizer();
$resizer->toHeight(1000);
$result = $resizer->resizeDown($size);
$this->assertEquals(800, $result->getWidth());
$this->assertEquals(600, $result->getHeight());
$this->assertEquals(800, $result->width());
$this->assertEquals(600, $result->height());
}
public function testScale()
@ -141,8 +141,8 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(1000);
$resizer->toHeight(2000);
$result = $resizer->scale($size);
$this->assertEquals(1000, $result->getWidth());
$this->assertEquals(750, $result->getHeight());
$this->assertEquals(1000, $result->width());
$this->assertEquals(750, $result->height());
// 800x600 > 2000x1000 = 1333x1000
$size = new Rectangle(800, 600);
@ -150,24 +150,24 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(2000);
$resizer->toHeight(1000);
$result = $resizer->scale($size);
$this->assertEquals(1333, $result->getWidth());
$this->assertEquals(1000, $result->getHeight());
$this->assertEquals(1333, $result->width());
$this->assertEquals(1000, $result->height());
// // 800x600 > nullx3000 = 4000x3000
$size = new Rectangle(800, 600);
$resizer = new RectangleResizer();
$resizer->toHeight(3000);
$result = $resizer->scale($size);
$this->assertEquals(4000, $result->getWidth());
$this->assertEquals(3000, $result->getHeight());
$this->assertEquals(4000, $result->width());
$this->assertEquals(3000, $result->height());
// // 800x600 > 8000xnull = 8000x6000
$size = new Rectangle(800, 600);
$resizer = new RectangleResizer();
$resizer->toWidth(8000);
$result = $resizer->scale($size);
$this->assertEquals(8000, $result->getWidth());
$this->assertEquals(6000, $result->getHeight());
$this->assertEquals(8000, $result->width());
$this->assertEquals(6000, $result->height());
// // 800x600 > 100x400 = 100x75
$size = new Rectangle(800, 600);
@ -175,8 +175,8 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(100);
$resizer->toHeight(400);
$result = $resizer->scale($size);
$this->assertEquals(100, $result->getWidth());
$this->assertEquals(75, $result->getHeight());
$this->assertEquals(100, $result->width());
$this->assertEquals(75, $result->height());
// // 800x600 > 400x100 = 133x100
$size = new Rectangle(800, 600);
@ -184,40 +184,40 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(400);
$resizer->toHeight(100);
$result = $resizer->scale($size);
$this->assertEquals(133, $result->getWidth());
$this->assertEquals(100, $result->getHeight());
$this->assertEquals(133, $result->width());
$this->assertEquals(100, $result->height());
// // 800x600 > nullx300 = 400x300
$size = new Rectangle(800, 600);
$resizer = new RectangleResizer();
$resizer->toHeight(300);
$result = $resizer->scale($size);
$this->assertEquals(400, $result->getWidth());
$this->assertEquals(300, $result->getHeight());
$this->assertEquals(400, $result->width());
$this->assertEquals(300, $result->height());
// // 800x600 > 80xnull = 80x60
$size = new Rectangle(800, 600);
$resizer = new RectangleResizer();
$resizer->toWidth(80);
$result = $resizer->scale($size);
$this->assertEquals(80, $result->getWidth());
$this->assertEquals(60, $result->getHeight());
$this->assertEquals(80, $result->width());
$this->assertEquals(60, $result->height());
// // 640x480 > 225xnull = 225x169
$size = new Rectangle(640, 480);
$resizer = new RectangleResizer();
$resizer->toWidth(225);
$result = $resizer->scale($size);
$this->assertEquals(225, $result->getWidth());
$this->assertEquals(169, $result->getHeight());
$this->assertEquals(225, $result->width());
$this->assertEquals(169, $result->height());
// // 640x480 > 223xnull = 223x167
$size = new Rectangle(640, 480);
$resizer = new RectangleResizer();
$resizer->toWidth(223);
$result = $resizer->scale($size);
$this->assertEquals(223, $result->getWidth());
$this->assertEquals(167, $result->getHeight());
$this->assertEquals(223, $result->width());
$this->assertEquals(167, $result->height());
// // 600x800 > 300x300 = 225x300
$size = new Rectangle(600, 800);
@ -225,8 +225,8 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(300);
$resizer->toHeight(300);
$result = $resizer->scale($size);
$this->assertEquals(225, $result->getWidth());
$this->assertEquals(300, $result->getHeight());
$this->assertEquals(225, $result->width());
$this->assertEquals(300, $result->height());
// // 800x600 > 400x10 = 13x10
$size = new Rectangle(800, 600);
@ -234,8 +234,8 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(400);
$resizer->toHeight(10);
$result = $resizer->scale($size);
$this->assertEquals(13, $result->getWidth());
$this->assertEquals(10, $result->getHeight());
$this->assertEquals(13, $result->width());
$this->assertEquals(10, $result->height());
// // 800x600 > 1000x1200 = 1000x750
$size = new Rectangle(800, 600);
@ -243,32 +243,32 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(1000);
$resizer->toHeight(1200);
$result = $resizer->scale($size);
$this->assertEquals(1000, $result->getWidth());
$this->assertEquals(750, $result->getHeight());
$this->assertEquals(1000, $result->width());
$this->assertEquals(750, $result->height());
$size = new Rectangle(12000, 12);
$resizer = new RectangleResizer();
$resizer->toWidth(4000);
$resizer->toHeight(3000);
$result = $resizer->scale($size);
$this->assertEquals(4000, $result->getWidth());
$this->assertEquals(4, $result->getHeight());
$this->assertEquals(4000, $result->width());
$this->assertEquals(4, $result->height());
$size = new Rectangle(12, 12000);
$resizer = new RectangleResizer();
$resizer->toWidth(4000);
$resizer->toHeight(3000);
$result = $resizer->scale($size);
$this->assertEquals(3, $result->getWidth());
$this->assertEquals(3000, $result->getHeight());
$this->assertEquals(3, $result->width());
$this->assertEquals(3000, $result->height());
$size = new Rectangle(12000, 6000);
$resizer = new RectangleResizer();
$resizer->toWidth(4000);
$resizer->toHeight(3000);
$result = $resizer->scale($size);
$this->assertEquals(4000, $result->getWidth());
$this->assertEquals(2000, $result->getHeight());
$this->assertEquals(4000, $result->width());
$this->assertEquals(2000, $result->height());
}
public function testScaleDown()
@ -278,91 +278,91 @@ class RectangleResizerTest extends TestCase
$resizer->toWidth(1000);
$resizer->toHeight(2000);
$result = $resizer->scaleDown($size);
$this->assertEquals(800, $result->getWidth());
$this->assertEquals(600, $result->getHeight());
$this->assertEquals(800, $result->width());
$this->assertEquals(600, $result->height());
$size = new Rectangle(800, 600);
$resizer = new RectangleResizer();
$resizer->toWidth(1000);
$resizer->toHeight(600);
$result = $resizer->scaleDown($size);
$this->assertEquals(800, $result->getWidth());
$this->assertEquals(600, $result->getHeight());
$this->assertEquals(800, $result->width());
$this->assertEquals(600, $result->height());
$size = new Rectangle(800, 600);
$resizer = new RectangleResizer();
$resizer->toWidth(1000);
$resizer->toHeight(300);
$result = $resizer->scaleDown($size);
$this->assertEquals(400, $result->getWidth());
$this->assertEquals(300, $result->getHeight());
$this->assertEquals(400, $result->width());
$this->assertEquals(300, $result->height());
$size = new Rectangle(800, 600);
$resizer = new RectangleResizer();
$resizer->toWidth(400);
$resizer->toHeight(1000);
$result = $resizer->scaleDown($size);
$this->assertEquals(400, $result->getWidth());
$this->assertEquals(300, $result->getHeight());
$this->assertEquals(400, $result->width());
$this->assertEquals(300, $result->height());
$size = new Rectangle(800, 600);
$resizer = new RectangleResizer();
$resizer->toWidth(400);
$result = $resizer->scaleDown($size);
$this->assertEquals(400, $result->getWidth());
$this->assertEquals(300, $result->getHeight());
$this->assertEquals(400, $result->width());
$this->assertEquals(300, $result->height());
$size = new Rectangle(800, 600);
$resizer = new RectangleResizer();
$resizer->toHeight(300);
$result = $resizer->scaleDown($size);
$this->assertEquals(400, $result->getWidth());
$this->assertEquals(300, $result->getHeight());
$this->assertEquals(400, $result->width());
$this->assertEquals(300, $result->height());
$size = new Rectangle(800, 600);
$resizer = new RectangleResizer();
$resizer->toWidth(1000);
$result = $resizer->scaleDown($size);
$this->assertEquals(800, $result->getWidth());
$this->assertEquals(600, $result->getHeight());
$this->assertEquals(800, $result->width());
$this->assertEquals(600, $result->height());
$size = new Rectangle(800, 600);
$resizer = new RectangleResizer();
$resizer->toHeight(1000);
$result = $resizer->scaleDown($size);
$this->assertEquals(800, $result->getWidth());
$this->assertEquals(600, $result->getHeight());
$this->assertEquals(800, $result->width());
$this->assertEquals(600, $result->height());
$size = new Rectangle(800, 600);
$resizer = new RectangleResizer();
$resizer->toWidth(100);
$result = $resizer->scaleDown($size);
$this->assertEquals(100, $result->getWidth());
$this->assertEquals(75, $result->getHeight());
$this->assertEquals(100, $result->width());
$this->assertEquals(75, $result->height());
$size = new Rectangle(800, 600);
$resizer = new RectangleResizer();
$resizer->toWidth(300);
$resizer->toHeight(200);
$result = $resizer->scaleDown($size);
$this->assertEquals(267, $result->getWidth());
$this->assertEquals(200, $result->getHeight());
$this->assertEquals(267, $result->width());
$this->assertEquals(200, $result->height());
$size = new Rectangle(600, 800);
$resizer = new RectangleResizer();
$resizer->toWidth(300);
$resizer->toHeight(300);
$result = $resizer->scaleDown($size);
$this->assertEquals(225, $result->getWidth());
$this->assertEquals(300, $result->getHeight());
$this->assertEquals(225, $result->width());
$this->assertEquals(300, $result->height());
$size = new Rectangle(800, 600);
$resizer = new RectangleResizer();
$resizer->toWidth(400);
$resizer->toHeight(10);
$result = $resizer->scaleDown($size);
$this->assertEquals(13, $result->getWidth());
$this->assertEquals(10, $result->getHeight());
$this->assertEquals(13, $result->width());
$this->assertEquals(10, $result->height());
}
/**
@ -373,8 +373,8 @@ class RectangleResizerTest extends TestCase
$resizer = new RectangleResizer();
$resizer->toSize($target);
$resized = $resizer->cover($origin);
$this->assertEquals($result->getWidth(), $resized->getWidth());
$this->assertEquals($result->getHeight(), $resized->getHeight());
$this->assertEquals($result->width(), $resized->width());
$this->assertEquals($result->height(), $resized->height());
}
public function coverDataProvider(): array
@ -400,8 +400,8 @@ class RectangleResizerTest extends TestCase
$resizer = new RectangleResizer();
$resizer->toSize($target);
$resized = $resizer->contain($origin);
$this->assertEquals($result->getWidth(), $resized->getWidth());
$this->assertEquals($result->getHeight(), $resized->getHeight());
$this->assertEquals($result->width(), $resized->width());
$this->assertEquals($result->height(), $resized->height());
}
public function containDataProvider(): array
@ -427,8 +427,8 @@ class RectangleResizerTest extends TestCase
$resizer = new RectangleResizer();
$resizer->toSize($target);
$resized = $resizer->crop($origin, $position);
$this->assertEquals($result->getWidth(), $resized->getWidth());
$this->assertEquals($result->getHeight(), $resized->getHeight());
$this->assertEquals($result->width(), $resized->width());
$this->assertEquals($result->height(), $resized->height());
$this->assertEquals($result->getPivot()->getX(), $resized->getPivot()->getX());
$this->assertEquals($result->getPivot()->getY(), $resized->getPivot()->getY());
}

View File

@ -19,32 +19,32 @@ class RectangleTest extends TestCase
$this->assertEquals(-200, $rectangle[2]->getY());
$this->assertEquals(0, $rectangle[3]->getX());
$this->assertEquals(-200, $rectangle[3]->getY());
$this->assertEquals(300, $rectangle->getWidth());
$this->assertEquals(200, $rectangle->getHeight());
$this->assertEquals(300, $rectangle->width());
$this->assertEquals(200, $rectangle->height());
}
public function testSetSize(): void
{
$rectangle = new Rectangle(300, 200);
$rectangle->setSize(12, 34);
$this->assertEquals(12, $rectangle->getWidth());
$this->assertEquals(34, $rectangle->getHeight());
$this->assertEquals(12, $rectangle->width());
$this->assertEquals(34, $rectangle->height());
}
public function testSetWidth(): void
{
$rectangle = new Rectangle(300, 200);
$this->assertEquals(300, $rectangle->getWidth());
$this->assertEquals(300, $rectangle->width());
$rectangle->setWidth(400);
$this->assertEquals(400, $rectangle->getWidth());
$this->assertEquals(400, $rectangle->width());
}
public function testSetHeight(): void
{
$rectangle = new Rectangle(300, 200);
$this->assertEquals(200, $rectangle->getHeight());
$this->assertEquals(200, $rectangle->height());
$rectangle->setHeight(800);
$this->assertEquals(800, $rectangle->getHeight());
$this->assertEquals(800, $rectangle->height());
}
public function testGetAspectRatio()

View File

@ -71,8 +71,8 @@ class TextBlockTest extends TestCase
$font->shouldReceive('capHeight')->andReturn(22);
$box = $block->getBoundingBox($font, new Point(10, 15));
$this->assertEquals(300, $box->getWidth());
$this->assertEquals(82, $box->getHeight());
$this->assertEquals(300, $box->width());
$this->assertEquals(82, $box->height());
$this->assertEquals(10, $box->getPivot()->getX());
$this->assertEquals(15, $box->getPivot()->getY());
}