本文整理汇总了PHP中ImagickPixel::getHSL方法的典型用法代码示例。如果您正苦于以下问题:PHP ImagickPixel::getHSL方法的具体用法?PHP ImagickPixel::getHSL怎么用?PHP ImagickPixel::getHSL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImagickPixel
的用法示例。
在下文中一共展示了ImagickPixel::getHSL方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: render
public function render()
{
//Example ImagickPixel::getHSL
$colorString = 'rgb(90%, 10%, 10%)';
$output = "The result of getHSL for the color '{$colorString}' is:<br/>";
$color = new \ImagickPixel($colorString);
$colorInfo = $color->getHSL();
foreach ($colorInfo as $key => $value) {
$output .= "{$key} : {$value} <br/>";
}
return $output;
//Example end
}
示例3: whirlyGif
function whirlyGif($numberDots, $numberFrames, $loopTime, $backgroundColor, $phaseMultiplier, $phaseDivider)
{
$aniGif = new \Imagick();
$aniGif->setFormat("gif");
$width = 500;
$height = $width;
$numberDots = intval($numberDots);
if ($numberDots < 1) {
$numberDots = 1;
}
$maxFrames = $numberFrames;
$frameDelay = ceil($loopTime / $maxFrames);
$scale = 1;
$startColor = new \ImagickPixel('red');
$dots = [];
for ($i = 0; $i < $numberDots; $i++) {
$colorInfo = $startColor->getHSL();
//Rotate the hue by 180 degrees
$newHue = $colorInfo['hue'] + $i / $numberDots;
if ($newHue > 1) {
$newHue = $newHue - 1;
}
//Set the ImagickPixel to the new color
$color = new \ImagickPixel('#ffffff');
$colorInfo['saturation'] *= 0.95;
$color->setHSL($newHue, $colorInfo['saturation'], $colorInfo['luminosity']);
$dots[] = new Dot($color, $i, $numberDots, $width, $height);
}
for ($frame = 0; $frame < $maxFrames; $frame++) {
$draw = new \ImagickDraw();
$draw->setStrokeColor('none');
$draw->setFillColor('none');
$draw->rectangle(0, 0, $width, $height);
$draw->translate($width / 2, $height / 2);
foreach ($dots as $dot) {
/** @var $dot Dot */
$dot->render($draw, $frame, $maxFrames, $phaseMultiplier, $phaseDivider);
}
//Create an image object which the draw commands can be rendered into
$imagick = new \Imagick();
$imagick->newImage($width * $scale, $height * $scale, $backgroundColor);
$imagick->setImageFormat("png");
$imagick->setImageDispose(\Imagick::DISPOSE_PREVIOUS);
//Render the draw commands in the ImagickDraw object
//into the image.
$imagick->drawImage($draw);
$imagick->setImageDelay($frameDelay);
$aniGif->addImage($imagick);
$imagick->destroy();
}
$aniGif->setImageFormat('gif');
$aniGif->setImageIterations(0);
//loop forever
$aniGif->mergeImageLayers(\Imagick::LAYERMETHOD_OPTIMIZEPLUS);
header("Content-Type: image/gif");
echo $aniGif->getImagesBlob();
}
示例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==