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


PHP ImagickPixel类代码示例

本文整理汇总了PHP中ImagickPixel的典型用法代码示例。如果您正苦于以下问题:PHP ImagickPixel类的具体用法?PHP ImagickPixel怎么用?PHP ImagickPixel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ImagickPixel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: createImage

 private function createImage()
 {
     /* Create Imagick object */
     $this->Imagick = new \Imagick();
     /* Create the ImagickPixel object (used to set the background color on image) */
     $bg = new \ImagickPixel();
     /* Set the pixel color to white */
     $bg->setColor($this->bg_color);
     /* Create a drawing object and set the font size */
     $ImagickDraw = new \ImagickDraw();
     /* Set font and font size. You can also specify /path/to/font.ttf */
     if ($this->font) {
         $ImagickDraw->setFont($this->font);
     }
     $ImagickDraw->setFontSize($this->font_size);
     /* Create new empty image */
     $this->Imagick->newImage($this->image_width, $this->image_height, $bg);
     /* Write the text on the image */
     $this->Imagick->annotateImage($ImagickDraw, $this->text_position_left, $this->text_position_top, 0, $this->getCaptchaText());
     /* Add some swirl */
     $this->Imagick->swirlImage(20);
     /* Create a few random lines */
     $ImagickDraw->line(rand(0, $this->image_width), rand(0, $this->image_height), rand(0, $this->image_width), rand(0, $this->image_height));
     $ImagickDraw->line(rand(0, $this->image_width), rand(0, $this->image_height), rand(0, $this->image_width), rand(0, $this->image_height));
     $ImagickDraw->line(rand(0, $this->image_width), rand(0, $this->image_height), rand(0, $this->image_width), rand(0, $this->image_height));
     $ImagickDraw->line(rand(0, $this->image_width), rand(0, $this->image_height), rand(0, $this->image_width), rand(0, $this->image_height));
     $ImagickDraw->line(rand(0, $this->image_width), rand(0, $this->image_height), rand(0, $this->image_width), rand(0, $this->image_height));
     /* Draw the ImagickDraw object contents to the image. */
     $this->Imagick->drawImage($ImagickDraw);
     /* Give the image a format */
     $this->Imagick->setImageFormat($this->image_format);
 }
开发者ID:xepan,项目名称:base,代码行数:32,代码来源:Captcha.php

示例3: create

    /**
     * (non-PHPdoc)
     * @see Imagine\Image\ImagineInterface::create()
     */
    public function create(BoxInterface $size, Color $color = null)
    {
        $width  = $size->getWidth();
        $height = $size->getHeight();

        $color = null !== $color ? $color : new Color('fff');

        try {
            $pixel = new \ImagickPixel((string) $color);
            $pixel->setColorValue(
                \Imagick::COLOR_OPACITY,
                number_format(abs(round($color->getAlpha() / 100, 1)), 1)
            );

            $imagick = new \Imagick();
            $imagick->newImage($width, $height, $pixel);
            $imagick->setImageMatte(true);
            $imagick->setImageBackgroundColor($pixel);

            $pixel->clear();
            $pixel->destroy();

            return new Image($imagick);
        } catch (\ImagickException $e) {
            throw new RuntimeException(
                'Could not create empty image', $e->getCode(), $e
            );
        }
    }
开发者ID:ndusan,项目名称:bginfobox,代码行数:33,代码来源:Imagine.php

示例4: render

 public function render()
 {
     //Example ImagickPixel::isSimilar
     // The tests below are written with the maximum distance expressed as 255
     // so we need to scale them by the square root of 3 - the diagonal length
     // of a unit cube.
     $root3 = 1.732050807568877;
     $tests = array(['rgb(245, 0, 0)', 'rgb(255, 0, 0)', 9 / $root3, false], ['rgb(245, 0, 0)', 'rgb(255, 0, 0)', 10 / $root3, true], ['rgb(0, 0, 0)', 'rgb(7, 7, 0)', 9 / $root3, false], ['rgb(0, 0, 0)', 'rgb(7, 7, 0)', 10 / $root3, true], ['rgba(0, 0, 0, 1)', 'rgba(7, 7, 0, 1)', 9 / $root3, false], ['rgba(0, 0, 0, 1)', 'rgba(7, 7, 0, 1)', 10 / $root3, true], ['rgb(128, 128, 128)', 'rgb(128, 128, 120)', 7 / $root3, false], ['rgb(128, 128, 128)', 'rgb(128, 128, 120)', 8 / $root3, true], ['rgb(0, 0, 0)', 'rgb(255, 255, 255)', 254.9, false], ['rgb(0, 0, 0)', 'rgb(255, 255, 255)', 255, true], ['rgb(255, 0, 0)', 'rgb(0, 255, 255)', 254.9, false], ['rgb(255, 0, 0)', 'rgb(0, 255, 255)', 255, true], ['black', 'rgba(0, 0, 0)', 0.0, true], ['black', 'rgba(10, 0, 0, 1.0)', 10.0 / $root3, true]);
     $output = "<table width='100%' class='infoTable'><thead>\n                <tr>\n                <th>\n                Color 1\n                </th>\n                <th>\n                Color 2\n                </th>\n                <th>\n                    Test distance * 255\n                </th>\n                <th>\n                    Is within distance\n                </th>\n                </tr>\n        </thead>";
     $output .= "<tbody>";
     foreach ($tests as $testInfo) {
         $color1 = $testInfo[0];
         $color2 = $testInfo[1];
         $distance = $testInfo[2];
         $expectation = $testInfo[3];
         $testDistance = $distance / 255.0;
         $color1Pixel = new \ImagickPixel($color1);
         $color2Pixel = new \ImagickPixel($color2);
         $isSimilar = $color1Pixel->isPixelSimilar($color2Pixel, $testDistance);
         if ($isSimilar !== $expectation) {
             echo "Test distance failed. Color [{$color1}] compared to color [{$color2}] is not within distance {$testDistance} FAILED." . NL;
         }
         $layout = "<tr>\n                <td>%s</td>\n                <td>%s</td>\n                <td>%s</td>\n                <td style='text-align: center;'>%s</td>\n            </tr>";
         $output .= sprintf($layout, $color1, $color2, $distance, $isSimilar ? 'yes' : 'no');
     }
     $output .= "</tbody></table>";
     return $output;
     //Example end
 }
开发者ID:finelinePG,项目名称:imagick,代码行数:29,代码来源:isPixelSimilar.php

示例5: render

 public function render()
 {
     //Example ImagickPixel::getColorAsString
     $output = "Create an ImagickPixel with the predefined color 'brown' and output the result of `getColorAsString`. <br/>";
     $color = new \ImagickPixel('brown');
     $color->setColorValue(\Imagick::COLOR_ALPHA, 64 / 256.0);
     $output .= $color->getColorAsString();
     return $output;
     //Example end
 }
开发者ID:finelinePG,项目名称:imagick,代码行数:10,代码来源:getColorAsString.php

示例6: render

 function render()
 {
     //Example ImagickPixel::getColorCount
     $output = "I have pretty much no idea what this function is meant " . "to do...if you know I'd love to hear.<br/>";
     $color = new \ImagickPixel('red');
     $colorInfo = $color->getColorCount();
     $output .= var_export($colorInfo, true);
     return $output;
     //Example end
 }
开发者ID:sdmmember,项目名称:Imagick-demos,代码行数:10,代码来源:getColorCount.php

示例7: addBlockForPixel

 /**
  * Add a Block to a pixel to a given coordinate depending
  * on a pixels color
  *
  * @param \ImagickPixel $pixel
  * @param Structure     $structure
  * @param               $x
  * @param               $y
  * @param               $z
  */
 protected function addBlockForPixel(\ImagickPixel $pixel, Structure $structure, $x, $y, $z)
 {
     $color = $pixel->getColor();
     $type = $this->blockTypeColorMapping->getBlockTypeForRgbColor($color['r'], $color['g'], $color['b']);
     if (null === $type) {
         return;
     }
     // if meta is null it becomes 0
     $meta = (int) $type->getMeta();
     $structure->createBlock($type->getName(), array('x' => $x, 'y' => $y, 'z' => $z), $meta);
 }
开发者ID:gries,项目名称:mcontrol,代码行数:21,代码来源:ImageToStructureConverter.php

示例8: render

 function render()
 {
     //Example ImagickPixel::getColorValueQuantum
     $color = new \ImagickPixel('rgb(128, 5, 255)');
     $colorRed = $color->getColorValueQuantum(\Imagick::COLOR_RED);
     $colorGreen = $color->getColorValueQuantum(\Imagick::COLOR_GREEN);
     $colorBlue = $color->getColorValueQuantum(\Imagick::COLOR_BLUE);
     $colorAlpha = $color->getColorValueQuantum(\Imagick::COLOR_ALPHA);
     printf("Red: %s Green: %s  Blue %s Alpha: %s", $colorRed, $colorGreen, $colorBlue, $colorAlpha);
     //Example end
 }
开发者ID:sdmmember,项目名称:Imagick-demos,代码行数:11,代码来源:getColorValueQuantum.php

示例9: 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                            &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);
 }
开发者ID:finelinePG,项目名称:imagick,代码行数:12,代码来源:ColorElement.php

示例10: 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

示例11: render

 public function render()
 {
     echo "Create an ImagickPixel with the predefined color 'brown' and set the color to have an alpha of 25% <br/>";
     //Example ImagickPixel::getColor
     $color = new \ImagickPixel('brown');
     $color->setColorValue(\Imagick::COLOR_ALPHA, 0.25);
     echo "<h4>Standard values</h4>" . PHP_EOL;
     foreach ($color->getColor() as $key => $value) {
         echo "{$key} : {$value} <br/>";
     }
     echo "<br/>";
     echo "<h4>Normalized values</h4>" . PHP_EOL;
     foreach ($color->getColor(true) as $key => $value) {
         echo "{$key} : {$value} <br/>";
     }
     //Example end
 }
开发者ID:atawsports2,项目名称:Imagick-demos,代码行数:17,代码来源:getColor.php

示例12: create

 public function create(BoxInterface $size, ColorInterface $color = null)
 {
     $width = $size->getWidth();
     $height = $size->getHeight();
     $color = self::getColor($color);
     try {
         $pixel = new \ImagickPixel($color['color']);
         $pixel->setColorValue(\Imagick::COLOR_OPACITY, $color['alpha']);
         $magick = new \Imagick();
         $magick->newImage($width, $height, $pixel);
         $magick->setImageMatte(true);
         $magick->setImageBackgroundColor($pixel);
         $pixel->clear();
         $pixel->destroy();
         return new RImage($magick, $color['palette'], self::$emptyBag, array($width, $height));
     } catch (\Exception $e) {
         throw new \Imagine\Exception\RuntimeException("Imagick: Could not create empty image {$e->getMessage()}", $e->getCode(), $e);
     }
 }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:19,代码来源:RImagine.php

示例13: render

 public function render()
 {
     //Example ImagickPixel::getColorValue
     $color = new \ImagickPixel('rgba(90%, 20%, 20%, 0.75)');
     echo "Alpha value is " . $color->getColorValue(\Imagick::COLOR_ALPHA) . "<br/>";
     echo "" . "<br/>";
     echo "Red value is " . $color->getColorValue(\Imagick::COLOR_RED) . "<br/>";
     echo "Green value is " . $color->getColorValue(\Imagick::COLOR_GREEN) . "<br/>";
     echo "Blue value is " . $color->getColorValue(\Imagick::COLOR_BLUE) . "<br/>";
     echo "" . "<br/>";
     echo "Cyan value is " . $color->getColorValue(\Imagick::COLOR_CYAN) . "<br/>";
     echo "Magenta value is " . $color->getColorValue(\Imagick::COLOR_MAGENTA) . "<br/>";
     echo "Yellow value is " . $color->getColorValue(\Imagick::COLOR_YELLOW) . "<br/>";
     echo "Black value is " . $color->getColorValue(\Imagick::COLOR_BLACK) . "<br/>";
     //Example end
 }
开发者ID:atawsports2,项目名称:Imagick-demos,代码行数:16,代码来源:getColorValue.php

示例14: rotate

 public function rotate($angle, \Imagine\Image\Palette\Color\ColorInterface $background = null)
 {
     if ($this->image === null) {
         $this->load();
     }
     $color = RImagine::getColor($background);
     try {
         $pixel = new \ImagickPixel($color['color']);
         $pixel->setColorValue(\Imagick::COLOR_OPACITY, $color['alpha']);
         $magick = $this->image->getImagick();
         $magick->rotateimage($pixel, $angle);
         $pixel->clear();
         $pixel->destroy();
         $magick->setImagePage(0, 0, 0, 0);
         // reset canvas position
     } catch (\ImagickException $e) {
         throw new \Imagine\Exception\RuntimeException('Imagick: Rotate operation failed. ' . $e->getMessage(), $e->getCode(), $e);
     }
     $this->size = array($magick->getImageWidth(), $magick->getImageHeight());
     return $this;
 }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:21,代码来源:RImage.php

示例15: render

 function render()
 {
     $output = "<table class='smallPadding' width='100%'>";
     $output .= "<tbody>";
     foreach ($this->listOfColors as $color) {
         $pixelColor = new \ImagickPixel($color);
         $colorArray = $pixelColor->getColor();
         if ($color == 'transparent' || $color == 'none') {
             $rgbaString = sprintf("rgb(%d, %d, %d, %d)", $colorArray['r'], $colorArray['g'], $colorArray['b'], $colorArray['a']);
             $hexString = sprintf("#%02x%02x%02x%02x", $colorArray['r'], $colorArray['g'], $colorArray['b'], $colorArray['a']);
         } else {
             $rgbaString = sprintf("rgb(%d, %d, %d)", $colorArray['r'], $colorArray['g'], $colorArray['b']);
             $hexString = sprintf("#%02x%02x%02x", $colorArray['r'], $colorArray['g'], $colorArray['b']);
         }
         $colorString = '';
         if ($colorArray['r'] + $colorArray['g'] + $colorArray['b'] < 200) {
             if ($colorArray['a'] != 0) {
                 $colorString = 'color: #efefef';
             }
         }
         $output .= "<tr>";
         $output .= "<td>";
         $output .= $color;
         $output .= "</td>";
         $output .= "<td style='background-color: {$hexString};{$colorString}'>";
         $output .= $color;
         $output .= "</td>";
         $output .= "<td>";
         $output .= $rgbaString;
         $output .= "</td>";
         $output .= "<td>";
         $output .= $hexString;
         $output .= "</td>";
         $output .= "</tr>";
     }
     $output .= "</tbody>";
     $output .= "</table>";
     return $output;
 }
开发者ID:sdmmember,项目名称:Imagick-demos,代码行数:39,代码来源:listColors.php


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