mirror of
https://github.com/Intervention/image.git
synced 2025-08-21 13:11:18 +02:00
Add tests for ColorspaceInterface::colorFromNormalized()
This commit is contained in:
@@ -18,6 +18,17 @@ use Intervention\Image\Tests\TestCase;
|
||||
*/
|
||||
class ColorspaceTest extends TestCase
|
||||
{
|
||||
public function testColorFromNormalized(): void
|
||||
{
|
||||
$colorspace = new Colorspace();
|
||||
$result = $colorspace->colorFromNormalized([0, 1, 0, 1]);
|
||||
$this->assertInstanceOf(CmykColor::class, $result);
|
||||
$this->assertEquals(0, $result->channel(Cyan::class)->value());
|
||||
$this->assertEquals(100, $result->channel(Magenta::class)->value());
|
||||
$this->assertEquals(0, $result->channel(Yellow::class)->value());
|
||||
$this->assertEquals(100, $result->channel(Key::class)->value());
|
||||
}
|
||||
|
||||
public function testImportRgbColor(): void
|
||||
{
|
||||
$colorspace = new Colorspace();
|
||||
|
@@ -17,6 +17,16 @@ use Intervention\Image\Tests\TestCase;
|
||||
*/
|
||||
class ColorspaceTest extends TestCase
|
||||
{
|
||||
public function testColorFromNormalized(): void
|
||||
{
|
||||
$colorspace = new Colorspace();
|
||||
$result = $colorspace->colorFromNormalized([1, 0, 1]);
|
||||
$this->assertInstanceOf(HslColor::class, $result);
|
||||
$this->assertEquals(360, $result->channel(Hue::class)->value());
|
||||
$this->assertEquals(0, $result->channel(Saturation::class)->value());
|
||||
$this->assertEquals(100, $result->channel(Luminance::class)->value());
|
||||
}
|
||||
|
||||
public function testImportRgbColor(): void
|
||||
{
|
||||
$colorspace = new Colorspace();
|
||||
|
@@ -17,6 +17,16 @@ use Intervention\Image\Tests\TestCase;
|
||||
*/
|
||||
class ColorspaceTest extends TestCase
|
||||
{
|
||||
public function testColorFromNormalized(): void
|
||||
{
|
||||
$colorspace = new Colorspace();
|
||||
$result = $colorspace->colorFromNormalized([1, 0, 1]);
|
||||
$this->assertInstanceOf(HsvColor::class, $result);
|
||||
$this->assertEquals(360, $result->channel(Hue::class)->value());
|
||||
$this->assertEquals(0, $result->channel(Saturation::class)->value());
|
||||
$this->assertEquals(100, $result->channel(Value::class)->value());
|
||||
}
|
||||
|
||||
public function testImportRgbColor(): void
|
||||
{
|
||||
$colorspace = new Colorspace();
|
||||
|
@@ -9,6 +9,7 @@ use Intervention\Image\Colors\Rgb\Channels\Green;
|
||||
use Intervention\Image\Colors\Rgb\Channels\Red;
|
||||
use Intervention\Image\Colors\Rgb\Color as RgbColor;
|
||||
use Intervention\Image\Colors\Hsl\Color as HslColor;
|
||||
use Intervention\Image\Colors\Rgb\Channels\Alpha;
|
||||
use Intervention\Image\Colors\Rgb\Colorspace;
|
||||
use Intervention\Image\Tests\TestCase;
|
||||
|
||||
@@ -17,6 +18,18 @@ use Intervention\Image\Tests\TestCase;
|
||||
*/
|
||||
class ColorspaceTest extends TestCase
|
||||
{
|
||||
public function testColorFromNormalized(): void
|
||||
{
|
||||
$colorspace = new Colorspace();
|
||||
|
||||
$result = $colorspace->colorFromNormalized([1, 0, 1, 1]);
|
||||
$this->assertInstanceOf(RgbColor::class, $result);
|
||||
$this->assertEquals(255, $result->channel(Red::class)->value());
|
||||
$this->assertEquals(0, $result->channel(Green::class)->value());
|
||||
$this->assertEquals(255, $result->channel(Blue::class)->value());
|
||||
$this->assertEquals(255, $result->channel(Alpha::class)->value());
|
||||
}
|
||||
|
||||
public function testImportCmykColor(): void
|
||||
{
|
||||
$colorspace = new Colorspace();
|
||||
|
Reference in New Issue
Block a user