예제 #1
0
 /**
  * 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;
 }
예제 #2
0
 /**
  * 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;
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function blend(ColorInterface $color1, ColorInterface $color2, $amount)
 {
     if (!$color1 instanceof GrayColor || !$color2 instanceof GrayColor) {
         throw new RuntimeException('Grayscale palette can only blend Grayscale colors');
     }
     return $this->color(array((int) min(255, min($color1->getGray(), $color2->getGray()) + round(abs($color2->getGray() - $color1->getGray()) * $amount))), (int) min(100, min($color1->getAlpha(), $color2->getAlpha()) + round(abs($color2->getAlpha() - $color1->getAlpha()) * $amount)));
 }
예제 #4
0
파일: Image.php 프로젝트: luoshulin/falcon
 /**
  * Gets specifically formatted color string from Color instance
  *
  * @param ColorInterface $color
  *
  * @return string
  */
 private function getColor(ColorInterface $color)
 {
     if (!$color->isOpaque()) {
         throw new InvalidArgumentException('Gmagick doesn\'t support transparency');
     }
     $pixel = new \GmagickPixel((string) $color);
     $pixel->setColorValue(\Gmagick::COLOR_OPACITY, number_format(abs(round($color->getAlpha() / 100, 1)), 1));
     return $pixel;
 }
예제 #5
0
파일: Image.php 프로젝트: mm999/EduSoho
 /**
  * Internal
  *
  * Generates a GD color from Color instance
  *
  * @param ColorInterface $color
  *
  * @return integer A color identifier
  *
  * @throws RuntimeException
  * @throws InvalidArgumentException
  */
 private function getColor(ColorInterface $color)
 {
     if (!$color instanceof RGBColor) {
         throw new InvalidArgumentException('GD driver only supports RGB colors');
     }
     $index = imagecolorallocatealpha($this->resource, $color->getRed(), $color->getGreen(), $color->getBlue(), round(127 * (100 - $color->getAlpha()) / 100));
     if (false === $index) {
         throw new RuntimeException(sprintf('Unable to allocate color "RGB(%s, %s, %s)" with transparency of %d percent', $color->getRed(), $color->getGreen(), $color->getBlue(), $color->getAlpha()));
     }
     return $index;
 }