1
0
mirror of https://github.com/Intervention/image.git synced 2025-03-15 22:49:40 +01:00

Revert "Rename methods of ImageInterface"

This reverts commit ba01e87883b18a8da728db8bcab8f50429315ede.
This commit is contained in:
Oliver Vogel 2023-10-07 10:25:41 +02:00
parent 4ff9abd3a0
commit d9f4c2440a
42 changed files with 121 additions and 138 deletions

View File

@ -217,11 +217,11 @@ abstract class AbstractImage implements ImageInterface
);
}
public function getColors(int $x, int $y): CollectionInterface
public function pickColors(int $x, int $y): CollectionInterface
{
$colors = new Collection();
foreach ($this as $key => $frame) {
$colors->push($this->getColor($x, $y, $key));
$colors->push($this->pickColor($x, $y, $key));
}
return $colors;

View File

@ -66,7 +66,7 @@ class Image extends AbstractImage implements ImageInterface, IteratorAggregate
return imagesy($this->getFrame()->getCore());
}
public function getColor(int $x, int $y, int $frame_key = 0): ?ColorInterface
public function pickColor(int $x, int $y, int $frame_key = 0): ?ColorInterface
{
if ($frame = $this->getFrame($frame_key)) {
return new Color(imagecolorat($frame->getCore(), $x, $y));

View File

@ -121,7 +121,7 @@ class Image extends AbstractImage implements ImageInterface, Iterator
return $this->getFrame()->getCore()->getImageHeight();
}
public function getColor(int $x, int $y, int $frame_key = 0): ?ColorInterface
public function pickColor(int $x, int $y, int $frame_key = 0): ?ColorInterface
{
if ($frame = $this->getFrame($frame_key)) {
return new Color($frame->getCore()->getImagePixelColor($x, $y));

View File

@ -3,6 +3,7 @@
namespace Intervention\Image\Interfaces;
use Countable;
use Intervention\Image\Collection;
use Intervention\Image\EncodedImage;
use Traversable;
@ -137,26 +138,8 @@ interface ImageInterface extends Traversable, Countable
*/
public function toPng(): EncodedImage;
/**
* Return color of pixel at the given position of the image
* For animated image pass the key of the animation frame.
*
* @param int $x
* @param int $y
* @param int $frame_key
* @return null|ColorInterface
*/
public function getColor(int $x, int $y, int $frame_key = 0): ?ColorInterface;
/**
* Return a collection with the color of the pixel at the given position
* For animated images all pixel colors for all frames are returned.
*
* @param int $x
* @param int $y
* @return CollectionInterface
*/
public function getColors(int $x, int $y): CollectionInterface;
public function pickColor(int $x, int $y, int $frame_key = 0): ?ColorInterface;
public function pickColors(int $x, int $y): CollectionInterface;
/**
* Draw text on image

View File

@ -297,12 +297,12 @@ class AbstractImageTest extends TestCase
$this->assertInstanceOf(ImageInterface::class, $result);
}
public function testGetColors(): void
public function testPickColors(): void
{
$color = Mockery::mock(ColorInterface::class);
$img = $this->abstractImageMock();
$img->shouldReceive('getColor')->times(3)->andReturn($color);
$result = $img->getColors(1, 2);
$img->shouldReceive('pickColor')->times(3)->andReturn($color);
$result = $img->pickColors(1, 2);
$this->assertInstanceOf(Collection::class, $result);
}

View File

@ -92,33 +92,33 @@ class ImageTest extends TestCase
$this->assertInstanceOf(Rectangle::class, $this->image->getSize());
}
public function testGetColor(): void
public function testPickColor(): void
{
$color = $this->image->getColor(0, 0);
$color = $this->image->pickColor(0, 0);
$this->assertInstanceOf(Color::class, $color);
$this->assertEquals(255, $color->red());
$this->assertEquals(0, $color->green());
$this->assertEquals(0, $color->blue());
$color = $this->image->getColor(0, 0, 1);
$color = $this->image->pickColor(0, 0, 1);
$this->assertInstanceOf(Color::class, $color);
$this->assertEquals(0, $color->red());
$this->assertEquals(255, $color->green());
$this->assertEquals(0, $color->blue());
$color = $this->image->getColor(0, 0, 2);
$color = $this->image->pickColor(0, 0, 2);
$this->assertInstanceOf(Color::class, $color);
$this->assertEquals(0, $color->red());
$this->assertEquals(0, $color->green());
$this->assertEquals(255, $color->blue());
$color = $this->image->getColor(0, 0, 3);
$color = $this->image->pickColor(0, 0, 3);
$this->assertNull($color);
}
public function testGetColors(): void
public function testPickColors(): void
{
$colors = $this->image->getColors(0, 0);
$colors = $this->image->pickColors(0, 0);
$this->assertInstanceOf(Collection::class, $colors);
$this->assertCount(3, $colors);

View File

@ -17,8 +17,8 @@ class BlurModifierTest extends TestCase
public function testColorChange(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(14, 14)->toHex());
$image->modify(new BlurModifier(30));
$this->assertEquals('4fa68d', $image->getColor(14, 14)->toHex());
$this->assertEquals('4fa68d', $image->pickColor(14, 14)->toHex());
}
}

View File

@ -17,8 +17,8 @@ class BrightnessModifierTest extends TestCase
public function testApply(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(14, 14)->toHex());
$image->modify(new BrightnessModifier(30));
$this->assertEquals('4cfaff', $image->getColor(14, 14)->toHex());
$this->assertEquals('4cfaff', $image->pickColor(14, 14)->toHex());
}
}

View File

@ -17,8 +17,8 @@ class ContrastModifierTest extends TestCase
public function testApply(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(14, 14)->toHex());
$image->modify(new ContrastModifier(30));
$this->assertEquals('00ceff', $image->getColor(14, 14)->toHex());
$this->assertEquals('00ceff', $image->pickColor(14, 14)->toHex());
}
}

View File

@ -19,10 +19,10 @@ class DrawEllipseModifierTest extends TestCase
public function testApply(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(14, 14)->toHex());
$drawable = new Ellipse(10, 10);
$drawable->background('b53717');
$image->modify(new DrawEllipseModifier(new Point(14, 14), $drawable));
$this->assertEquals('b53717', $image->getColor(14, 14)->toHex());
$this->assertEquals('b53717', $image->pickColor(14, 14)->toHex());
}
}

View File

@ -19,10 +19,10 @@ class DrawLineModifierTest extends TestCase
public function testApply(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(14, 14)->toHex());
$line = new Line(new Point(0, 0), new Point(10, 0), 4);
$line->background('b53517');
$image->modify(new DrawLineModifier(new Point(0, 0), $line));
$this->assertEquals('b53517', $image->getColor(0, 0)->toHex());
$this->assertEquals('b53517', $image->pickColor(0, 0)->toHex());
}
}

View File

@ -18,8 +18,8 @@ class DrawPixelModifierTest extends TestCase
public function testApply(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(14, 14)->toHex());
$image->modify(new DrawPixelModifier(new Point(14, 14), 'ffffff'));
$this->assertEquals('ffffff', $image->getColor(14, 14)->toHex());
$this->assertEquals('ffffff', $image->pickColor(14, 14)->toHex());
}
}

View File

@ -19,10 +19,10 @@ class DrawPolygonModifierTest extends TestCase
public function testApply(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(14, 14)->toHex());
$drawable = new Polygon([new Point(0, 0), new Point(15, 15), new Point(20, 20)]);
$drawable->background('b53717');
$image->modify(new DrawPolygonModifier($drawable));
$this->assertEquals('b53717', $image->getColor(14, 14)->toHex());
$this->assertEquals('b53717', $image->pickColor(14, 14)->toHex());
}
}

View File

@ -19,10 +19,10 @@ class DrawRectangleModifierTest extends TestCase
public function testApply(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(14, 14)->toHex());
$rectangle = new Rectangle(300, 200);
$rectangle->background('ffffff');
$image->modify(new DrawRectangleModifier(new Point(14, 14), $rectangle));
$this->assertEquals('ffffff', $image->getColor(14, 14)->toHex());
$this->assertEquals('ffffff', $image->pickColor(14, 14)->toHex());
}
}

View File

@ -19,20 +19,20 @@ class FillModifierTest extends TestCase
public function testFloodFillColor(): void
{
$image = $this->createTestImage('blocks.png');
$this->assertEquals('0000ff', $image->getColor(420, 270)->toHex());
$this->assertEquals('ff0000', $image->getColor(540, 400)->toHex());
$this->assertEquals('0000ff', $image->pickColor(420, 270)->toHex());
$this->assertEquals('ff0000', $image->pickColor(540, 400)->toHex());
$image->modify(new FillModifier(new Color(13421772), new Point(540, 400)));
$this->assertEquals('0000ff', $image->getColor(420, 270)->toHex());
$this->assertEquals('cccccc', $image->getColor(540, 400)->toHex());
$this->assertEquals('0000ff', $image->pickColor(420, 270)->toHex());
$this->assertEquals('cccccc', $image->pickColor(540, 400)->toHex());
}
public function testFillAllColor(): void
{
$image = $this->createTestImage('blocks.png');
$this->assertEquals('0000ff', $image->getColor(420, 270)->toHex());
$this->assertEquals('ff0000', $image->getColor(540, 400)->toHex());
$this->assertEquals('0000ff', $image->pickColor(420, 270)->toHex());
$this->assertEquals('ff0000', $image->pickColor(540, 400)->toHex());
$image->modify(new FillModifier(new Color(13421772)));
$this->assertEquals('cccccc', $image->getColor(420, 270)->toHex());
$this->assertEquals('cccccc', $image->getColor(540, 400)->toHex());
$this->assertEquals('cccccc', $image->pickColor(420, 270)->toHex());
$this->assertEquals('cccccc', $image->pickColor(540, 400)->toHex());
}
}

View File

@ -22,9 +22,9 @@ class FitModifierTest extends TestCase
$image->modify(new FitModifier(100, 100, 'center'));
$this->assertEquals(100, $image->getWidth());
$this->assertEquals(100, $image->getHeight());
$this->assertColor(255, 0, 0, 1, $image->getColor(90, 90));
$this->assertColor(0, 255, 0, 1, $image->getColor(65, 70));
$this->assertColor(0, 0, 255, 1, $image->getColor(70, 52));
$this->assertTransparency($image->getColor(90, 30));
$this->assertColor(255, 0, 0, 1, $image->pickColor(90, 90));
$this->assertColor(0, 255, 0, 1, $image->pickColor(65, 70));
$this->assertColor(0, 0, 255, 1, $image->pickColor(70, 52));
$this->assertTransparency($image->pickColor(90, 30));
}
}

View File

@ -19,16 +19,16 @@ class FlipFlopModifierTest extends TestCase
public function testFlipImage(): void
{
$image = $this->createTestImage('tile.png');
$this->assertEquals('b4e000', $image->getColor(0, 0)->toHex());
$this->assertEquals('b4e000', $image->pickColor(0, 0)->toHex());
$image->modify(new FlipModifier());
$this->assertEquals('000000', $image->getColor(0, 0)->toHex());
$this->assertEquals('000000', $image->pickColor(0, 0)->toHex());
}
public function testFlopImage(): void
{
$image = $this->createTestImage('tile.png');
$this->assertEquals('b4e000', $image->getColor(0, 0)->toHex());
$this->assertEquals('b4e000', $image->pickColor(0, 0)->toHex());
$image->modify(new FlopModifier());
$this->assertEquals('000000', $image->getColor(0, 0)->toHex());
$this->assertEquals('000000', $image->pickColor(0, 0)->toHex());
}
}

View File

@ -17,8 +17,8 @@ class GammaModifierTest extends TestCase
public function testModifier(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(0, 0)->toHex());
$this->assertEquals('00aef0', $image->pickColor(0, 0)->toHex());
$image->modify(new GammaModifier(2.1));
$this->assertEquals('00d5f8', $image->getColor(0, 0)->toHex());
$this->assertEquals('00d5f8', $image->pickColor(0, 0)->toHex());
}
}

View File

@ -17,8 +17,8 @@ class GreyscaleModifierTest extends TestCase
public function testColorChange(): void
{
$image = $this->createTestImage('trim.png');
$this->assertFalse($image->getColor(0, 0)->isGreyscale());
$this->assertFalse($image->pickColor(0, 0)->isGreyscale());
$image->modify(new GreyscaleModifier());
$this->assertTrue($image->getColor(0, 0)->isGreyscale());
$this->assertTrue($image->pickColor(0, 0)->isGreyscale());
}
}

View File

@ -17,10 +17,10 @@ class InvertModifierTest extends TestCase
public function testApply(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(0, 0)->toHex());
$this->assertEquals('ffa601', $image->getColor(25, 25)->toHex());
$this->assertEquals('00aef0', $image->pickColor(0, 0)->toHex());
$this->assertEquals('ffa601', $image->pickColor(25, 25)->toHex());
$image->modify(new InvertModifier());
$this->assertEquals('ff510f', $image->getColor(0, 0)->toHex());
$this->assertEquals('0059fe', $image->getColor(25, 25)->toHex());
$this->assertEquals('ff510f', $image->pickColor(0, 0)->toHex());
$this->assertEquals('0059fe', $image->pickColor(25, 25)->toHex());
}
}

View File

@ -17,10 +17,10 @@ class PixelateModifierTest extends TestCase
public function testModify(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(0, 0)->toHex());
$this->assertEquals('00aef0', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(0, 0)->toHex());
$this->assertEquals('00aef0', $image->pickColor(14, 14)->toHex());
$image->modify(new PixelateModifier(10));
$this->assertEquals('00aef0', $image->getColor(0, 0)->toHex());
$this->assertEquals('6aaa8b', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(0, 0)->toHex());
$this->assertEquals('6aaa8b', $image->pickColor(14, 14)->toHex());
}
}

View File

@ -17,8 +17,8 @@ class PlaceModifierTest extends TestCase
public function testColorChange(): void
{
$image = $this->createTestImage('test.jpg');
$this->assertEquals('febc44', $image->getColor(300, 25)->toHex());
$this->assertEquals('febc44', $image->pickColor(300, 25)->toHex());
$image->modify(new PlaceModifier(__DIR__ . '/../../../images/circle.png', 'top-right', 0, 0));
$this->assertEquals('32250d', $image->getColor(300, 25)->toHex());
$this->assertEquals('32250d', $image->pickColor(300, 25)->toHex());
}
}

View File

@ -22,10 +22,10 @@ class ResizeModifierTest extends TestCase
$image->modify(new ResizeModifier(200, 100));
$this->assertEquals(200, $image->getWidth());
$this->assertEquals(100, $image->getHeight());
$this->assertColor(255, 0, 0, 1, $image->getColor(150, 70));
$this->assertColor(0, 255, 0, 1, $image->getColor(125, 70));
$this->assertColor(0, 0, 255, 1, $image->getColor(130, 54));
$transparent = $image->getColor(170, 30);
$this->assertColor(255, 0, 0, 1, $image->pickColor(150, 70));
$this->assertColor(0, 255, 0, 1, $image->pickColor(125, 70));
$this->assertColor(0, 0, 255, 1, $image->pickColor(130, 54));
$transparent = $image->pickColor(170, 30);
$this->assertEquals(2130706432, $transparent->toInt());
$this->assertTransparency($transparent);
}

View File

@ -17,8 +17,8 @@ class SharpenModifierTest extends TestCase
public function testModify(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('60ab96', $image->getColor(15, 14)->toHex());
$this->assertEquals('60ab96', $image->pickColor(15, 14)->toHex());
$image->modify(new SharpenModifier(10));
$this->assertEquals('4daba7', $image->getColor(15, 14)->toHex());
$this->assertEquals('4daba7', $image->pickColor(15, 14)->toHex());
}
}

View File

@ -17,8 +17,8 @@ class BlurModifierTest extends TestCase
public function testColorChange(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(14, 14)->toHex());
$image->modify(new BlurModifier(30));
$this->assertEquals('42acb2', $image->getColor(14, 14)->toHex());
$this->assertEquals('42acb2', $image->pickColor(14, 14)->toHex());
}
}

View File

@ -17,8 +17,8 @@ class BrightnessModifierTest extends TestCase
public function testApply(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(14, 14)->toHex());
$image->modify(new BrightnessModifier(30));
$this->assertEquals('39c9ff', $image->getColor(14, 14)->toHex());
$this->assertEquals('39c9ff', $image->pickColor(14, 14)->toHex());
}
}

View File

@ -17,8 +17,8 @@ class ContrastModifierTest extends TestCase
public function testApply(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(14, 14)->toHex());
$image->modify(new ContrastModifier(30));
$this->assertEquals('00fcff', $image->getColor(14, 14)->toHex());
$this->assertEquals('00fcff', $image->pickColor(14, 14)->toHex());
}
}

View File

@ -15,10 +15,10 @@ class DrawEllipseModifierTest extends TestCase
public function testApply(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(14, 14)->toHex());
$drawable = new Ellipse(10, 10);
$drawable->background('b53717');
$image->modify(new DrawEllipseModifier(new Point(14, 14), $drawable));
$this->assertEquals('b53717', $image->getColor(14, 14)->toHex());
$this->assertEquals('b53717', $image->pickColor(14, 14)->toHex());
}
}

View File

@ -15,10 +15,10 @@ class DrawLineModifierTest extends TestCase
public function testApply(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(14, 14)->toHex());
$line = new Line(new Point(0, 0), new Point(10, 0), 4);
$line->background('b53517');
$image->modify(new DrawLineModifier(new Point(0, 0), $line));
$this->assertEquals('b53517', $image->getColor(0, 0)->toHex());
$this->assertEquals('b53517', $image->pickColor(0, 0)->toHex());
}
}

View File

@ -18,8 +18,8 @@ class DrawPixelModifierTest extends TestCase
public function testApply(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(14, 14)->toHex());
$image->modify(new DrawPixelModifier(new Point(14, 14), 'ffffff'));
$this->assertEquals('ffffff', $image->getColor(14, 14)->toHex());
$this->assertEquals('ffffff', $image->pickColor(14, 14)->toHex());
}
}

View File

@ -15,10 +15,10 @@ class DrawPolygonModifierTest extends TestCase
public function testApply(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(14, 14)->toHex());
$drawable = new Polygon([new Point(0, 0), new Point(15, 15), new Point(20, 20)]);
$drawable->background('b53717');
$image->modify(new DrawPolygonModifier($drawable));
$this->assertEquals('b53717', $image->getColor(14, 14)->toHex());
$this->assertEquals('b53717', $image->pickColor(14, 14)->toHex());
}
}

View File

@ -15,10 +15,10 @@ class DrawRectangleModifierTest extends TestCase
public function testApply(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(14, 14)->toHex());
$rectangle = new Rectangle(300, 200);
$rectangle->background('ffffff');
$image->modify(new DrawRectangleModifier(new Point(14, 14), $rectangle));
$this->assertEquals('ffffff', $image->getColor(14, 14)->toHex());
$this->assertEquals('ffffff', $image->pickColor(14, 14)->toHex());
}
}

View File

@ -20,20 +20,20 @@ class FillModifierTest extends TestCase
public function testFloodFillColor(): void
{
$image = $this->createTestImage('blocks.png');
$this->assertEquals('0000ff', $image->getColor(420, 270)->toHex());
$this->assertEquals('ff0000', $image->getColor(540, 400)->toHex());
$this->assertEquals('0000ff', $image->pickColor(420, 270)->toHex());
$this->assertEquals('ff0000', $image->pickColor(540, 400)->toHex());
$image->modify(new FillModifier(new Color(new ImagickPixel('#cccccc')), new Point(540, 400)));
$this->assertEquals('0000ff', $image->getColor(420, 270)->toHex());
$this->assertEquals('cccccc', $image->getColor(540, 400)->toHex());
$this->assertEquals('0000ff', $image->pickColor(420, 270)->toHex());
$this->assertEquals('cccccc', $image->pickColor(540, 400)->toHex());
}
public function testFillAllColor(): void
{
$image = $this->createTestImage('blocks.png');
$this->assertEquals('0000ff', $image->getColor(420, 270)->toHex());
$this->assertEquals('ff0000', $image->getColor(540, 400)->toHex());
$this->assertEquals('0000ff', $image->pickColor(420, 270)->toHex());
$this->assertEquals('ff0000', $image->pickColor(540, 400)->toHex());
$image->modify(new FillModifier(new Color(new ImagickPixel('#cccccc'))));
$this->assertEquals('cccccc', $image->getColor(420, 270)->toHex());
$this->assertEquals('cccccc', $image->getColor(540, 400)->toHex());
$this->assertEquals('cccccc', $image->pickColor(420, 270)->toHex());
$this->assertEquals('cccccc', $image->pickColor(540, 400)->toHex());
}
}

View File

@ -22,9 +22,9 @@ class FitModifierTest extends TestCase
$image->modify(new FitModifier(100, 100, 'center'));
$this->assertEquals(100, $image->getWidth());
$this->assertEquals(100, $image->getHeight());
$this->assertColor(255, 0, 0, 1, $image->getColor(90, 90));
$this->assertColor(0, 255, 0, 1, $image->getColor(65, 70));
$this->assertColor(0, 0, 255, 1, $image->getColor(70, 52));
$this->assertTransparency($image->getColor(90, 30));
$this->assertColor(255, 0, 0, 1, $image->pickColor(90, 90));
$this->assertColor(0, 255, 0, 1, $image->pickColor(65, 70));
$this->assertColor(0, 0, 255, 1, $image->pickColor(70, 52));
$this->assertTransparency($image->pickColor(90, 30));
}
}

View File

@ -19,16 +19,16 @@ class FlipFlopModifierTest extends TestCase
public function testFlipImage(): void
{
$image = $this->createTestImage('tile.png');
$this->assertEquals('b4e000', $image->getColor(0, 0)->toHex());
$this->assertEquals('b4e000', $image->pickColor(0, 0)->toHex());
$image->modify(new FlipModifier());
$this->assertEquals('000000', $image->getColor(0, 0)->toHex());
$this->assertEquals('000000', $image->pickColor(0, 0)->toHex());
}
public function testFlopImage(): void
{
$image = $this->createTestImage('tile.png');
$this->assertEquals('b4e000', $image->getColor(0, 0)->toHex());
$this->assertEquals('b4e000', $image->pickColor(0, 0)->toHex());
$image->modify(new FlopModifier());
$this->assertEquals('000000', $image->getColor(0, 0)->toHex());
$this->assertEquals('000000', $image->pickColor(0, 0)->toHex());
}
}

View File

@ -17,8 +17,8 @@ class GammaModifierTest extends TestCase
public function testModifier(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(0, 0)->toHex());
$this->assertEquals('00aef0', $image->pickColor(0, 0)->toHex());
$image->modify(new GammaModifier(2.1));
$this->assertEquals('00d5f8', $image->getColor(0, 0)->toHex());
$this->assertEquals('00d5f8', $image->pickColor(0, 0)->toHex());
}
}

View File

@ -17,8 +17,8 @@ class GreyscaleModifierTest extends TestCase
public function testColorChange(): void
{
$image = $this->createTestImage('trim.png');
$this->assertFalse($image->getColor(0, 0)->isGreyscale());
$this->assertFalse($image->pickColor(0, 0)->isGreyscale());
$image->modify(new GreyscaleModifier());
$this->assertTrue($image->getColor(0, 0)->isGreyscale());
$this->assertTrue($image->pickColor(0, 0)->isGreyscale());
}
}

View File

@ -17,10 +17,10 @@ class InvertModifierTest extends TestCase
public function testApply(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(0, 0)->toHex());
$this->assertEquals('ffa601', $image->getColor(25, 25)->toHex());
$this->assertEquals('00aef0', $image->pickColor(0, 0)->toHex());
$this->assertEquals('ffa601', $image->pickColor(25, 25)->toHex());
$image->modify(new InvertModifier());
$this->assertEquals('ff510f', $image->getColor(0, 0)->toHex());
$this->assertEquals('0059fe', $image->getColor(25, 25)->toHex());
$this->assertEquals('ff510f', $image->pickColor(0, 0)->toHex());
$this->assertEquals('0059fe', $image->pickColor(25, 25)->toHex());
}
}

View File

@ -17,10 +17,10 @@ class PixelateModifierTest extends TestCase
public function testModify(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('00aef0', $image->getColor(0, 0)->toHex());
$this->assertEquals('00aef0', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(0, 0)->toHex());
$this->assertEquals('00aef0', $image->pickColor(14, 14)->toHex());
$image->modify(new PixelateModifier(10));
$this->assertEquals('00aef0', $image->getColor(0, 0)->toHex());
$this->assertEquals('6bab8c', $image->getColor(14, 14)->toHex());
$this->assertEquals('00aef0', $image->pickColor(0, 0)->toHex());
$this->assertEquals('6bab8c', $image->pickColor(14, 14)->toHex());
}
}

View File

@ -17,8 +17,8 @@ class PlaceModifierTest extends TestCase
public function testColorChange(): void
{
$image = $this->createTestImage('test.jpg');
$this->assertEquals('febc44', $image->getColor(300, 25)->toHex());
$this->assertEquals('febc44', $image->pickColor(300, 25)->toHex());
$image->modify(new PlaceModifier(__DIR__ . '/../../../images/circle.png', 'top-right', 0, 0));
$this->assertEquals('33260e', $image->getColor(300, 25)->toHex());
$this->assertEquals('33260e', $image->pickColor(300, 25)->toHex());
}
}

View File

@ -22,9 +22,9 @@ class ResizeModifierTest extends TestCase
$image->modify(new ResizeModifier(200, 100));
$this->assertEquals(200, $image->getWidth());
$this->assertEquals(100, $image->getHeight());
$this->assertColor(255, 0, 0, 1, $image->getColor(150, 70));
$this->assertColor(0, 255, 0, 1, $image->getColor(125, 70));
$this->assertColor(0, 0, 255, 1, $image->getColor(130, 54));
$this->assertTransparency($image->getColor(150, 45));
$this->assertColor(255, 0, 0, 1, $image->pickColor(150, 70));
$this->assertColor(0, 255, 0, 1, $image->pickColor(125, 70));
$this->assertColor(0, 0, 255, 1, $image->pickColor(130, 54));
$this->assertTransparency($image->pickColor(150, 45));
}
}

View File

@ -17,8 +17,8 @@ class SharpenModifierTest extends TestCase
public function testModify(): void
{
$image = $this->createTestImage('trim.png');
$this->assertEquals('60ab96', $image->getColor(15, 14)->toHex());
$this->assertEquals('60ab96', $image->pickColor(15, 14)->toHex());
$image->modify(new SharpenModifier(10));
$this->assertEquals('4faca6', $image->getColor(15, 14)->toHex());
$this->assertEquals('4faca6', $image->pickColor(15, 14)->toHex());
}
}