本文整理汇总了PHP中Color::getAlpha方法的典型用法代码示例。如果您正苦于以下问题:PHP Color::getAlpha方法的具体用法?PHP Color::getAlpha怎么用?PHP Color::getAlpha使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Color
的用法示例。
在下文中一共展示了Color::getAlpha方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testInvalidColor
public function testInvalidColor()
{
$strColor = '-invalid-';
$color = new Color($strColor);
$this->assertEquals($strColor, $color->getColor());
$this->assertEquals(255, $color->getRed());
$this->assertEquals(255, $color->getGreen());
$this->assertEquals(255, $color->getBlue());
$this->assertEquals(0, $color->getAlpha());
}
示例2: testShouldSetColorToWhite
/**
* @cover Imagine\Image\Color::__construct
* @cover Imagine\Image\Color::getRed
* @cover Imagine\Image\Color::getGreen
* @cover Imagine\Image\Color::getAlpha
* @cover Imagine\Image\Color::__toString
*/
public function testShouldSetColorToWhite()
{
$color = new Color('fff');
$this->assertEquals(255, $color->getRed());
$this->assertEquals(255, $color->getGreen());
$this->assertEquals(255, $color->getBlue());
$this->assertEquals(0, $color->getAlpha());
$this->assertEquals('#ffffff', (string) $color);
$this->assertEquals('#00ff00', (string) new Color('00ff00'));
}
示例3: getColorIndex
/**
* @param \DarkLuk42\Color $color
* @param bool $forceAllocation
*
* @return int
*/
public function getColorIndex(Color $color, $forceAllocation = true)
{
if ($color->hasAlpha()) {
$index = imagecolorexactalpha($this->image, $color->getRed(), $color->getGreen(), $color->getBlue(), intval($color->getAlpha() / 2));
} else {
$index = imagecolorexact($this->image, $color->getRed(), $color->getGreen(), $color->getBlue());
}
if ($index == -1 && $forceAllocation) {
$index = $this->colorAllocate($color);
}
return $index;
}