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


PHP ImagickPixel::setColorValue方法代码示例

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


在下文中一共展示了ImagickPixel::setColorValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

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

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

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

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

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

示例6: create

 /**
  * {@inheritdoc}
  */
 public function create(BoxInterface $size, ColorInterface $color = null)
 {
     $width = $size->getWidth();
     $height = $size->getHeight();
     $palette = null !== $color ? $color->getPalette() : new RGB();
     $color = null !== $color ? $color : $palette->color('fff');
     try {
         $pixel = new \ImagickPixel((string) $color);
         $pixel->setColorValue(Imagick::COLOR_ALPHA, $color->getAlpha() / 100);
         $imagick = new Imagick();
         $imagick->newImage($width, $height, $pixel);
         $imagick->setImageMatte(true);
         $imagick->setImageBackgroundColor($pixel);
         if (version_compare('6.3.1', $this->getVersion($imagick)) < 0) {
             $imagick->setImageOpacity($pixel->getColorValue(Imagick::COLOR_ALPHA));
         }
         $pixel->clear();
         $pixel->destroy();
         return new Image($imagick, $palette, new MetadataBag());
     } catch (\ImagickException $e) {
         throw new RuntimeException('Could not create empty image', $e->getCode(), $e);
     }
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:26,代码来源:Imagine.php

示例7: getColor

 /**
  * Gets specifically formatted color string from Color instance
  *
  * @param ColorInterface $color
  *
  * @return \ImagickPixel
  */
 private function getColor(ColorInterface $color)
 {
     $pixel = new \ImagickPixel((string) $color);
     $pixel->setColorValue(\Imagick::COLOR_ALPHA, $color->getAlpha() / 100);
     return $pixel;
 }
开发者ID:scisahaha,项目名称:generator-craft,代码行数:13,代码来源:Image.php

示例8: getColor

 /**
  * Gets specifically formatted color string from Color instance
  *
  * @param ColorInterface $color
  *
  * @return \ImagickPixel
  */
 private function getColor(ColorInterface $color)
 {
     $pixel = new \ImagickPixel((string) $color);
     $pixel->setColorValue(\Imagick::COLOR_ALPHA, number_format(round($color->getAlpha() / 100, 2), 1));
     return $pixel;
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:13,代码来源:Image.php

示例9: getColor

 /**
  * Gets specifically formatted color string from Color instance
  *
  * @param Color $color
  *
  * @return string
  */
 private function getColor(Color $color)
 {
     $pixel = new \ImagickPixel((string) $color);
     $pixel->setColorValue(\Imagick::COLOR_OPACITY, number_format(abs(round($color->getAlpha() / 100, 1)), 1));
     return $pixel;
 }
开发者ID:rachelleannmorales,项目名称:aboitiz,代码行数:13,代码来源:Image.php

示例10: ImagickPixel

try {
    $pixel = new ImagickPixel('the-best-color-in-the-world');
} catch (ImagickPixelException $ex) {
    echo "__construct\n";
}
$pixel = new ImagickPixel('white');
try {
    $pixel->setColor('the-worst-color-in-the-world');
} catch (ImagickPixelException $ex) {
    echo "setColor\n";
}
define('IMAGICK_COLOR_INVALID', -1);
try {
    $pixel->getColorValue(IMAGICK_COLOR_INVALID);
} catch (ImagickPixelException $ex) {
    echo "getColorValue\n";
}
try {
    $pixel->setColorValue(IMAGICK_COLOR_INVALID, 0);
} catch (ImagickPixelException $ex) {
    echo "setColorValue\n";
}
try {
    $pixel->isPixelSimilar(new ImagickPixelException(), 0);
} catch (ImagickPixelException $ex) {
    echo "isPixelSimilar\n";
}
?>
==DONE==
开发者ID:badlamer,项目名称:hhvm,代码行数:29,代码来源:pixel_exception.php

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