本文整理汇总了PHP中ImagickPixel::getColor方法的典型用法代码示例。如果您正苦于以下问题:PHP ImagickPixel::getColor方法的具体用法?PHP ImagickPixel::getColor怎么用?PHP ImagickPixel::getColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImagickPixel
的用法示例。
在下文中一共展示了ImagickPixel::getColor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
public function render()
{
echo "Create an ImagickPixel with the predefined color 'brown' and set the color to have an alpha of 25% <br/>";
//Example ImagickPixel::getColor
$color = new \ImagickPixel('brown');
$color->setColorValue(\Imagick::COLOR_ALPHA, 0.25);
echo "<h4>Standard values</h4>" . PHP_EOL;
foreach ($color->getColor() as $key => $value) {
echo "{$key} : {$value} <br/>";
}
echo "<br/>";
echo "<h4>Normalized values</h4>" . PHP_EOL;
foreach ($color->getColor(true) as $key => $value) {
echo "{$key} : {$value} <br/>";
}
//Example end
}
示例2: addBlockForPixel
/**
* Add a Block to a pixel to a given coordinate depending
* on a pixels color
*
* @param \ImagickPixel $pixel
* @param Structure $structure
* @param $x
* @param $y
* @param $z
*/
protected function addBlockForPixel(\ImagickPixel $pixel, Structure $structure, $x, $y, $z)
{
$color = $pixel->getColor();
$type = $this->blockTypeColorMapping->getBlockTypeForRgbColor($color['r'], $color['g'], $color['b']);
if (null === $type) {
return;
}
// if meta is null it becomes 0
$meta = (int) $type->getMeta();
$structure->createBlock($type->getName(), array('x' => $x, 'y' => $y, 'z' => $z), $meta);
}
示例3: render
function render()
{
$output = "<table class='smallPadding' width='100%'>";
$output .= "<tbody>";
foreach ($this->listOfColors as $color) {
$pixelColor = new \ImagickPixel($color);
$colorArray = $pixelColor->getColor();
if ($color == 'transparent' || $color == 'none') {
$rgbaString = sprintf("rgb(%d, %d, %d, %d)", $colorArray['r'], $colorArray['g'], $colorArray['b'], $colorArray['a']);
$hexString = sprintf("#%02x%02x%02x%02x", $colorArray['r'], $colorArray['g'], $colorArray['b'], $colorArray['a']);
} else {
$rgbaString = sprintf("rgb(%d, %d, %d)", $colorArray['r'], $colorArray['g'], $colorArray['b']);
$hexString = sprintf("#%02x%02x%02x", $colorArray['r'], $colorArray['g'], $colorArray['b']);
}
$colorString = '';
if ($colorArray['r'] + $colorArray['g'] + $colorArray['b'] < 200) {
if ($colorArray['a'] != 0) {
$colorString = 'color: #efefef';
}
}
$output .= "<tr>";
$output .= "<td>";
$output .= $color;
$output .= "</td>";
$output .= "<td style='background-color: {$hexString};{$colorString}'>";
$output .= $color;
$output .= "</td>";
$output .= "<td>";
$output .= $rgbaString;
$output .= "</td>";
$output .= "<td>";
$output .= $hexString;
$output .= "</td>";
$output .= "</tr>";
}
$output .= "</tbody>";
$output .= "</table>";
return $output;
}
示例4: 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==
示例5: getColor
/**
* @param \ImagickPixel $px
* @param array $pixels
* @param int $x
* @param int $y
*
* @return float
*/
private function getColor($px, &$pixels, $x, $y)
{
if (isset($pixels[$x][$y])) {
return $pixels[$x][$y];
}
$rgba = $px->getColor();
return $pixels[$x][$y] = round($rgba['r'] * 0.3 + $rgba['g'] * 0.59 + $rgba['b'] * 0.11);
// gray
}