本文整理汇总了PHP中ImagickPixel::getcolor方法的典型用法代码示例。如果您正苦于以下问题:PHP ImagickPixel::getcolor方法的具体用法?PHP ImagickPixel::getcolor怎么用?PHP ImagickPixel::getcolor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImagickPixel
的用法示例。
在下文中一共展示了ImagickPixel::getcolor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
function render()
{
//Example ImagickPixel::setHSL
$output = "This example creates a red color, rotates the hue by 180 degrees and sets the new color.<br/>";
//Create an almost pure red color
$color = new \ImagickPixel('rgb(90%, 10%, 10%)');
$originalColor = clone $color;
//Get it's HSL values
$colorInfo = $color->getHSL();
//Rotate the hue by 180 degrees
$newHue = $colorInfo['hue'] + 0.5;
if ($newHue > 1) {
$newHue = $newHue - 1;
}
//Set the ImagickPixel to the new color
$color->setHSL($newHue, $colorInfo['saturation'], $colorInfo['luminosity']);
$output .= "<h3>Original color</h3>";
$colorInfo = $originalColor->getcolor();
foreach ($colorInfo as $key => $value) {
$output .= "{$key} : {$value} <br/>";
}
$output .= "<h3>Rotated color</h3>";
//Check that the new color is blue/green
$colorInfo = $color->getcolor();
foreach ($colorInfo as $key => $value) {
$output .= "{$key} : {$value} <br/>";
}
return $output;
//Example end
}
示例2: renderFormElement
public function renderFormElement()
{
$sValue = safeText($this->value);
$fillPixel = new \ImagickPixel($this->value);
$fillColor = $fillPixel->getcolor();
$fillString = sprintf("rgb(%d, %d, %d)", $fillColor['r'], $fillColor['g'], $fillColor['b']);
$fillStringHex = sprintf("%02x%02x%02x", $fillColor['r'], $fillColor['g'], $fillColor['b']);
$input = "<input type='text' class='inputValue' id='" . $this->getVariableName() . "' name='" . $this->getVariableName() . "' value='{$sValue}' />";
$color = "<span id='" . $this->getVariableName() . "Selector' data-color='0x{$fillStringHex}' style='display: inline-block; border: 1px solid #000; padding: 0px;'>\n <span style='background-color: {$fillString}; margin: 2px; width: 20px; display: inline-block;'>\n \n </span>\n </span>";
$text = "<div class='row controlRow'>\n <div class='col-sm-" . (self::FIRST_ELEMENT_SIZE - 1) . " " . self::FIRST_ELEMENT_CLASS . " controlCell'>\n %s\n </div>\n <div class='col-sm-1 controlCell'>\n %s\n </div>\n <div class='col-sm-" . self::MIDDLE_ELEMENT_SIZE . " " . self::MIDDLE_ELEMENT_CLASS . " controlCell'>\n %s\n </div>\n \n</div>";
return sprintf($text, $this->getDisplayName(), $color, $input);
}