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


PHP ImagickPixel::getColor方法代码示例

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


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

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

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

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

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

示例5: getColor

 /**
  * @param \ImagickPixel $px
  * @param array $pixels
  * @param int $x
  * @param int $y
  *
  * @return float
  */
 private function getColor($px, &$pixels, $x, $y)
 {
     if (isset($pixels[$x][$y])) {
         return $pixels[$x][$y];
     }
     $rgba = $px->getColor();
     return $pixels[$x][$y] = round($rgba['r'] * 0.3 + $rgba['g'] * 0.59 + $rgba['b'] * 0.11);
     // gray
 }
开发者ID:kosinix,项目名称:grafika,代码行数:17,代码来源:Sobel.php


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