1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-16 10:54:02 +02:00

Implement new method ColorInterface::isClear() (#1387)

This commit is contained in:
Oliver Vogel
2024-08-11 11:41:38 +02:00
committed by GitHub
parent 6196ff1eb9
commit 4a614ddfb8
9 changed files with 80 additions and 0 deletions

View File

@@ -152,4 +152,14 @@ class Color extends AbstractColor
{ {
return false; return false;
} }
/**
* {@inheritdoc}
*
* @see ColorInterface::isClear()
*/
public function isClear(): bool
{
return false;
}
} }

View File

@@ -120,4 +120,14 @@ class Color extends AbstractColor
{ {
return false; return false;
} }
/**
* {@inheritdoc}
*
* @see ColorInterface::isClear()
*/
public function isClear(): bool
{
return false;
}
} }

View File

@@ -120,4 +120,14 @@ class Color extends AbstractColor
{ {
return false; return false;
} }
/**
* {@inheritdoc}
*
* @see ColorInterface::isClear()
*/
public function isClear(): bool
{
return false;
}
} }

View File

@@ -178,4 +178,14 @@ class Color extends AbstractColor
{ {
return $this->alpha()->value() < $this->alpha()->max(); return $this->alpha()->value() < $this->alpha()->max();
} }
/**
* {@inheritdoc}
*
* @see ColorInterface::isClear()
*/
public function isClear(): bool
{
return $this->alpha()->value() == 0;
}
} }

View File

@@ -97,4 +97,11 @@ interface ColorInterface
* @return bool * @return bool
*/ */
public function isTransparent(): bool; public function isTransparent(): bool;
/**
* Determine whether the current color is completely transparent
*
* @return bool
*/
public function isClear(): bool;
} }

View File

@@ -111,4 +111,10 @@ final class ColorTest extends BaseTestCase
$color = new Color(100, 50, 50, 0); $color = new Color(100, 50, 50, 0);
$this->assertFalse($color->isTransparent()); $this->assertFalse($color->isTransparent());
} }
public function testIsClear(): void
{
$color = new Color(0, 0, 0, 0);
$this->assertFalse($color->isClear());
}
} }

View File

@@ -108,4 +108,10 @@ final class ColorTest extends BaseTestCase
$color = new Color(0, 1, 0); $color = new Color(0, 1, 0);
$this->assertFalse($color->isTransparent()); $this->assertFalse($color->isTransparent());
} }
public function testIsClear(): void
{
$color = new Color(0, 1, 0);
$this->assertFalse($color->isClear());
}
} }

View File

@@ -108,4 +108,10 @@ final class ColorTest extends BaseTestCase
$color = new Color(1, 0, 0); $color = new Color(1, 0, 0);
$this->assertFalse($color->isTransparent()); $this->assertFalse($color->isTransparent());
} }
public function testIsClear(): void
{
$color = new Color(0, 1, 0);
$this->assertFalse($color->isClear());
}
} }

View File

@@ -163,4 +163,19 @@ final class ColorTest extends BaseTestCase
$color = new Color(255, 255, 255, 0); $color = new Color(255, 255, 255, 0);
$this->assertTrue($color->isTransparent()); $this->assertTrue($color->isTransparent());
} }
public function testIsClear(): void
{
$color = new Color(255, 255, 255);
$this->assertFalse($color->isClear());
$color = new Color(255, 255, 255, 255);
$this->assertFalse($color->isClear());
$color = new Color(255, 255, 255, 85);
$this->assertFalse($color->isClear());
$color = new Color(255, 255, 255, 0);
$this->assertTrue($color->isClear());
}
} }