mirror of
https://github.com/Intervention/image.git
synced 2025-08-17 03:13:59 +02:00
Implement new method ColorInterface::isClear() (#1387)
This commit is contained in:
@@ -152,4 +152,14 @@ class Color extends AbstractColor
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @see ColorInterface::isClear()
|
||||||
|
*/
|
||||||
|
public function isClear(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -120,4 +120,14 @@ class Color extends AbstractColor
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @see ColorInterface::isClear()
|
||||||
|
*/
|
||||||
|
public function isClear(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -120,4 +120,14 @@ class Color extends AbstractColor
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @see ColorInterface::isClear()
|
||||||
|
*/
|
||||||
|
public function isClear(): bool
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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;
|
||||||
}
|
}
|
||||||
|
@@ -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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user