當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。