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


PHP ImagickPixel::getColorValue方法代码示例

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


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

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

示例2: pixelToColor

 /**
  * Returns a color given a pixel, depending the Palette context
  *
  * Note : this method is public for PHP 5.3 compatibility
  *
  * @param \ImagickPixel $pixel
  *
  * @return ColorInterface
  *
  * @throws InvalidArgumentException In case a unknown color is requested
  */
 public function pixelToColor(\ImagickPixel $pixel)
 {
     static $colorMapping = array(ColorInterface::COLOR_RED => \Imagick::COLOR_RED, ColorInterface::COLOR_GREEN => \Imagick::COLOR_GREEN, ColorInterface::COLOR_BLUE => \Imagick::COLOR_BLUE, ColorInterface::COLOR_CYAN => \Imagick::COLOR_CYAN, ColorInterface::COLOR_MAGENTA => \Imagick::COLOR_MAGENTA, ColorInterface::COLOR_YELLOW => \Imagick::COLOR_YELLOW, ColorInterface::COLOR_KEYLINE => \Imagick::COLOR_BLACK, ColorInterface::COLOR_GRAY => \Imagick::COLOR_RED);
     $alpha = $this->palette->supportsAlpha() ? (int) round($pixel->getColorValue(\Imagick::COLOR_ALPHA) * 100) : null;
     $palette = $this->palette();
     return $this->palette->color(array_map(function ($color) use($palette, $pixel, $colorMapping) {
         if (!isset($colorMapping[$color])) {
             throw new InvalidArgumentException(sprintf('Color %s is not mapped in Imagick', $color));
         }
         $multiplier = 255;
         if ($palette->name() === PaletteInterface::PALETTE_CMYK) {
             $multiplier = 100;
         }
         return $pixel->getColorValue($colorMapping[$color]) * $multiplier;
     }, $this->palette->pixelDefinition()), $alpha);
 }
开发者ID:scisahaha,项目名称:generator-craft,代码行数:27,代码来源:Image.php

示例3: ImagickPixel

<?php

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,代码行数:31,代码来源:pixel_exception.php

示例4: pixelToColor

 /**
  * Returns a color given a pixel, depending the Palette context
  *
  * Note : this method is public for PHP 5.3 compatibility
  *
  * @param \ImagickPixel $pixel
  *
  * @return ColorInterface
  *
  * @throws InvalidArgumentException In case a unknown color is requested
  */
 public function pixelToColor(\ImagickPixel $pixel)
 {
     static $colorMapping = array(ColorInterface::COLOR_RED => \Imagick::COLOR_RED, ColorInterface::COLOR_GREEN => \Imagick::COLOR_GREEN, ColorInterface::COLOR_BLUE => \Imagick::COLOR_BLUE, ColorInterface::COLOR_CYAN => \Imagick::COLOR_CYAN, ColorInterface::COLOR_MAGENTA => \Imagick::COLOR_MAGENTA, ColorInterface::COLOR_YELLOW => \Imagick::COLOR_YELLOW, ColorInterface::COLOR_KEYLINE => \Imagick::COLOR_BLACK);
     $alpha = $this->palette->supportsAlpha() ? (int) round($pixel->getColorValue(\Imagick::COLOR_ALPHA) * 100) : null;
     return $this->palette->color(array_map(function ($color) use($pixel, $colorMapping) {
         if (!isset($colorMapping[$color])) {
             throw new InvalidArgumentException('Color %s is not mapped in Imagick');
         }
         return $pixel->getColorValue($colorMapping[$color]) * 255;
     }, $this->palette->pixelDefinition()), $alpha);
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:22,代码来源:Image.php

示例5: getAlphaValue

 /**
  * Returns RGB alpha value of current color
  *
  * @return float
  */
 public function getAlphaValue()
 {
     return round($this->pixel->getColorValue(\Imagick::COLOR_ALPHA), 2);
 }
开发者ID:RHoKAustralia,项目名称:onaroll21_backend,代码行数:9,代码来源:Color.php

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