本文整理汇总了PHP中ImagickPixel::getColorValue方法的典型用法代码示例。如果您正苦于以下问题:PHP ImagickPixel::getColorValue方法的具体用法?PHP ImagickPixel::getColorValue怎么用?PHP ImagickPixel::getColorValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImagickPixel
的用法示例。
在下文中一共展示了ImagickPixel::getColorValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public function render()
{
//Example ImagickPixel::getColorValue
$color = new \ImagickPixel('rgba(90%, 20%, 20%, 0.75)');
echo "Alpha value is " . $color->getColorValue(\Imagick::COLOR_ALPHA) . "<br/>";
echo "" . "<br/>";
echo "Red value is " . $color->getColorValue(\Imagick::COLOR_RED) . "<br/>";
echo "Green value is " . $color->getColorValue(\Imagick::COLOR_GREEN) . "<br/>";
echo "Blue value is " . $color->getColorValue(\Imagick::COLOR_BLUE) . "<br/>";
echo "" . "<br/>";
echo "Cyan value is " . $color->getColorValue(\Imagick::COLOR_CYAN) . "<br/>";
echo "Magenta value is " . $color->getColorValue(\Imagick::COLOR_MAGENTA) . "<br/>";
echo "Yellow value is " . $color->getColorValue(\Imagick::COLOR_YELLOW) . "<br/>";
echo "Black value is " . $color->getColorValue(\Imagick::COLOR_BLACK) . "<br/>";
//Example end
}
示例2: pixelToColor
/**
* Returns a color given a pixel, depending the Palette context
*
* Note : this method is public for PHP 5.3 compatibility
*
* @param \ImagickPixel $pixel
*
* @return ColorInterface
*
* @throws InvalidArgumentException In case a unknown color is requested
*/
public function pixelToColor(\ImagickPixel $pixel)
{
static $colorMapping = array(ColorInterface::COLOR_RED => \Imagick::COLOR_RED, ColorInterface::COLOR_GREEN => \Imagick::COLOR_GREEN, ColorInterface::COLOR_BLUE => \Imagick::COLOR_BLUE, ColorInterface::COLOR_CYAN => \Imagick::COLOR_CYAN, ColorInterface::COLOR_MAGENTA => \Imagick::COLOR_MAGENTA, ColorInterface::COLOR_YELLOW => \Imagick::COLOR_YELLOW, ColorInterface::COLOR_KEYLINE => \Imagick::COLOR_BLACK, ColorInterface::COLOR_GRAY => \Imagick::COLOR_RED);
$alpha = $this->palette->supportsAlpha() ? (int) round($pixel->getColorValue(\Imagick::COLOR_ALPHA) * 100) : null;
$palette = $this->palette();
return $this->palette->color(array_map(function ($color) use($palette, $pixel, $colorMapping) {
if (!isset($colorMapping[$color])) {
throw new InvalidArgumentException(sprintf('Color %s is not mapped in Imagick', $color));
}
$multiplier = 255;
if ($palette->name() === PaletteInterface::PALETTE_CMYK) {
$multiplier = 100;
}
return $pixel->getColorValue($colorMapping[$color]) * $multiplier;
}, $this->palette->pixelDefinition()), $alpha);
}
示例3: ImagickPixel
<?php
try {
$pixel = new ImagickPixel('the-best-color-in-the-world');
} catch (ImagickPixelException $ex) {
echo "__construct\n";
}
$pixel = new ImagickPixel('white');
try {
$pixel->setColor('the-worst-color-in-the-world');
} catch (ImagickPixelException $ex) {
echo "setColor\n";
}
define('IMAGICK_COLOR_INVALID', -1);
try {
$pixel->getColorValue(IMAGICK_COLOR_INVALID);
} catch (ImagickPixelException $ex) {
echo "getColorValue\n";
}
try {
$pixel->setColorValue(IMAGICK_COLOR_INVALID, 0);
} catch (ImagickPixelException $ex) {
echo "setColorValue\n";
}
try {
$pixel->isPixelSimilar(new ImagickPixelException(), 0);
} catch (ImagickPixelException $ex) {
echo "isPixelSimilar\n";
}
?>
==DONE==
示例4: pixelToColor
/**
* Returns a color given a pixel, depending the Palette context
*
* Note : this method is public for PHP 5.3 compatibility
*
* @param \ImagickPixel $pixel
*
* @return ColorInterface
*
* @throws InvalidArgumentException In case a unknown color is requested
*/
public function pixelToColor(\ImagickPixel $pixel)
{
static $colorMapping = array(ColorInterface::COLOR_RED => \Imagick::COLOR_RED, ColorInterface::COLOR_GREEN => \Imagick::COLOR_GREEN, ColorInterface::COLOR_BLUE => \Imagick::COLOR_BLUE, ColorInterface::COLOR_CYAN => \Imagick::COLOR_CYAN, ColorInterface::COLOR_MAGENTA => \Imagick::COLOR_MAGENTA, ColorInterface::COLOR_YELLOW => \Imagick::COLOR_YELLOW, ColorInterface::COLOR_KEYLINE => \Imagick::COLOR_BLACK);
$alpha = $this->palette->supportsAlpha() ? (int) round($pixel->getColorValue(\Imagick::COLOR_ALPHA) * 100) : null;
return $this->palette->color(array_map(function ($color) use($pixel, $colorMapping) {
if (!isset($colorMapping[$color])) {
throw new InvalidArgumentException('Color %s is not mapped in Imagick');
}
return $pixel->getColorValue($colorMapping[$color]) * 255;
}, $this->palette->pixelDefinition()), $alpha);
}
示例5: getAlphaValue
/**
* Returns RGB alpha value of current color
*
* @return float
*/
public function getAlphaValue()
{
return round($this->pixel->getColorValue(\Imagick::COLOR_ALPHA), 2);
}
示例6: sprintf
return sprintf('%.3f', $matches[0]);
}, $ret);
echo "{$ret}\n";
}
$pixel = new ImagickPixel();
$pixel->setColor('yellow');
dump($pixel->getHSL());
dump($pixel->getColor(true));
$pixel = new ImagickPixel($pixel->getColorAsString());
dump($pixel->getHSL());
dump($pixel->getColor(false));
$pixel = new ImagickPixel();
$pixel->setHSL(0.3, 0.4, 0.5);
dump($pixel->getHSL());
dump($pixel->getColor(false));
$pixel = new ImagickPixel($pixel->getColorAsString());
dump($pixel->getHSL());
dump($pixel->getColor(true));
$pixel = new ImagickPixel('#F02B88');
$colors = array(Imagick::COLOR_BLACK, Imagick::COLOR_BLUE, Imagick::COLOR_CYAN, Imagick::COLOR_GREEN, Imagick::COLOR_RED, Imagick::COLOR_YELLOW, Imagick::COLOR_MAGENTA, Imagick::COLOR_ALPHA, Imagick::COLOR_FUZZ);
foreach ($colors as $color) {
dump($pixel->getColorValue($color));
}
foreach ($colors as $color) {
$pixel->setColorValue($color, $pixel->getColorValue($color));
}
dump($pixel->getHSL());
dump($pixel->getColor());
?>
==DONE==