mirror of
https://github.com/Intervention/image.git
synced 2025-08-10 07:53:58 +02:00
Add Geometry\Pixel::class
This commit is contained in:
28
src/Geometry/Pixel.php
Normal file
28
src/Geometry/Pixel.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Intervention\Image\Geometry;
|
||||||
|
|
||||||
|
use Intervention\Image\Interfaces\ColorInterface;
|
||||||
|
|
||||||
|
class Pixel extends Point
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
protected ColorInterface $background,
|
||||||
|
protected int $x,
|
||||||
|
protected int $y
|
||||||
|
) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
public function withBackground(ColorInterface $background): self
|
||||||
|
{
|
||||||
|
$this->background = $background;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function background(): ColorInterface
|
||||||
|
{
|
||||||
|
return $this->background;
|
||||||
|
}
|
||||||
|
}
|
23
tests/Geometry/PixelTest.php
Normal file
23
tests/Geometry/PixelTest.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Intervention\Image\Tests\Geometry;
|
||||||
|
|
||||||
|
use Intervention\Image\Geometry\Pixel;
|
||||||
|
use Intervention\Image\Interfaces\ColorInterface;
|
||||||
|
use Intervention\Image\Tests\TestCase;
|
||||||
|
use Mockery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers \Intervention\Image\Geometry\Pixel
|
||||||
|
*/
|
||||||
|
class PixelTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testSetGetBackground(): void
|
||||||
|
{
|
||||||
|
$color = Mockery::mock(ColorInterface::class);
|
||||||
|
$pixel = new Pixel($color, 10, 12);
|
||||||
|
$result = $pixel->withBackground($color);
|
||||||
|
$this->assertInstanceOf(ColorInterface::class, $pixel->background());
|
||||||
|
$this->assertInstanceOf(Pixel::class, $result);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user