本文整理匯總了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);
}