コード例 #1
0
ファイル: setHSL.php プロジェクト: sdmmember/Imagick-demos
 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
0
ファイル: ColorElement.php プロジェクト: finelinePG/imagick
 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                            &nbsp;\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);
 }