Exemplo n.º 1
0
 /**
  * Test distance
  */
 public function testDistance()
 {
     $this->assertGreaterThan(0.8, Color::create('ff0000')->distance('0000ff'));
     $this->assertLessThan(0.1, Color::create('ff0000')->distance('f80800'));
 }
Exemplo n.º 2
0
 /**
  * Filter method: colorize
  *
  * @param string|\Zork\Image\Color $color
  * @return \Zork\Image\Image
  * @throws \Zork\Image\FilterException
  * @codeCoverageIgnore
  */
 public function filterColorize($color = 'gray')
 {
     if (!$color instanceof Color) {
         $color = Color::create($color);
     }
     if (!imagefilter($this->resource, IMG_FILTER_COLORIZE, $color->getRed(), $color->getGreen(), $color->getBlue(), intval($color->getAlpha() * 127 / 255))) {
         throw new Exception\FilterException('Filter cannot execute');
     }
 }
Exemplo n.º 3
0
 /**
  * Test color fill & crop
  */
 public function testColorFillCrop()
 {
     $image = Image::create(200, 150, false);
     $this->assertTrue($image->getTransparent()->isTransparent());
     $image = Image::create(200, 150);
     $this->assertTrue($image->getTransparent()->isTransparent());
     $color = Color::create('red');
     $image->fill($color);
     $this->assertEquals($color, $image->colorAt(100, 75));
     $color = Color::create('green');
     $image->fill($color, 50, 50, 100, 50);
     $this->assertEquals($color, $image->colorAt(100, 75));
     $color = '0000ffff';
     $image->fill($color, -150, -50);
     $this->assertEquals(Color::create($color), $image->colorAt(-100, -25));
     $image->cropTo(50, 50, 100, 50);
     $this->assertEquals(100, $image->getWidth());
     $this->assertEquals(50, $image->getHeight());
     $this->assertEquals(Color::create('green'), $image->colorAt(50, 25));
     $image = null;
 }