diff --git a/tests/Colors/Cmyk/ColorspaceTest.php b/tests/Colors/Cmyk/ColorspaceTest.php index 69fca686..dacd8fed 100644 --- a/tests/Colors/Cmyk/ColorspaceTest.php +++ b/tests/Colors/Cmyk/ColorspaceTest.php @@ -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(); diff --git a/tests/Colors/Hsl/ColorspaceTest.php b/tests/Colors/Hsl/ColorspaceTest.php index 7ab48c50..365a8e7b 100644 --- a/tests/Colors/Hsl/ColorspaceTest.php +++ b/tests/Colors/Hsl/ColorspaceTest.php @@ -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(); diff --git a/tests/Colors/Hsv/ColorspaceTest.php b/tests/Colors/Hsv/ColorspaceTest.php index 297b6960..00def55a 100644 --- a/tests/Colors/Hsv/ColorspaceTest.php +++ b/tests/Colors/Hsv/ColorspaceTest.php @@ -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(); diff --git a/tests/Colors/Rgb/ColorspaceTest.php b/tests/Colors/Rgb/ColorspaceTest.php index 1ea0eb44..a79727d4 100644 --- a/tests/Colors/Rgb/ColorspaceTest.php +++ b/tests/Colors/Rgb/ColorspaceTest.php @@ -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();