Exemple #1
0
 /**
  * @dataProvider    validInputForCreation
  *
  * #depends         testCanBeCreatedFromValidInput
  *                  Sadly this is not supported by PHPUnit
  */
 public function testCanBeSerializedToRGBString($red, $green, $blue, $alpha, $hex, $rgb)
 {
     $color = new RGBColor($red, $green, $blue, $alpha);
     $string = $color->__toString();
     $this->assertEquals($rgb, $string);
 }
Exemple #2
0
 /**
  * Blend current color with the given new color and the amount
  *
  * @param RGBColor $color  another color
  * @param float    $amount The amount of curennt color in the given color
  *
  * @return \Jaguar\Color\RGBColor
  */
 public function blend(RGBColor $color, $amount)
 {
     return $this->setFromArray(array(min(255, min($this->getRed(), $color->getRed()) + round(abs($color->getRed() - $this->getRed()) * $amount)), min(255, min($this->getGreen(), $color->getGreen()) + round(abs($color->getGreen() - $this->getGreen()) * $amount)), min(255, min($this->getBlue(), $color->getBlue()) + round(abs($color->getBlue() - $this->getBlue()) * $amount)), min(100, min($this->getAlpha(), $color->getAlpha()) + round(abs($color->getAlpha() - $this->getAlpha()) * $amount))));
 }