Пример #1
0
 /**
  * Create a new adapter instance from a new empty image
  * 
  * @param int $width
  * @param int $height
  * @return \Phower\Image\Adapter\ImagickAdapter
  * @throws InvalidArgumentException
  */
 public static function create($width, $height, ColorInterface $background = null)
 {
     if ((int) $width < 1) {
         throw new InvalidArgumentException('Width must be greater than 0.');
     }
     if ((int) $height < 1) {
         throw new InvalidArgumentException('Height must be greater than 0.');
     }
     if ($background === null) {
         $background = new Color();
     }
     $resource = new Imagick();
     $resource->newimage($width, $height, $background->toRgba());
     return new static($resource);
 }
Пример #2
0
 /**
  * Create a new adapter instance from a new empty image
  * 
  * @param int $width
  * @param int $height
  * @param \Phower\Image\ColorInterface $background
  * @return \Phower\Image\Adapter\GdAdapter
  * @throws InvalidArgumentException
  */
 public static function create($width, $height, ColorInterface $background = null)
 {
     if ((int) $width < 1) {
         throw new InvalidArgumentException('Width must be greater than 0.');
     }
     if ((int) $height < 1) {
         throw new InvalidArgumentException('Height must be greater than 0.');
     }
     if ($background === null) {
         $background = new Color();
     }
     $resource = imagecreatetruecolor($width, $height);
     imagealphablending($resource, true);
     imagefill($resource, 0, 0, $background->toInt());
     return new static($resource);
 }
Пример #3
0
 public function testToRgbaMethodReturnsColorAsAStandardCssRgbaNotation()
 {
     $color = new Color(255, 204, 0, 64);
     $this->assertEquals('rgb(255, 204, 0, 0.503937)', $color->toRgba());
 }