当前位置: 首页>>代码示例>>PHP>>正文


PHP ImagickPixel::getHSL方法代码示例

本文整理汇总了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
 }
开发者ID:sdmmember,项目名称:Imagick-demos,代码行数:30,代码来源:setHSL.php

示例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
 }
开发者ID:atawsports2,项目名称:Imagick-demos,代码行数:13,代码来源:getHSL.php

示例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();
}
开发者ID:biswajit-paul,项目名称:gittest,代码行数:57,代码来源:functions.php

示例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==
开发者ID:badlamer,项目名称:hhvm,代码行数:30,代码来源:pixel_color.php


注:本文中的ImagickPixel::getHSL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。