/**
  * @dataProvider getRatios
  *
  * @param integer $ratio
  */
 public function testScale($ratio)
 {
     $box = new Box();
     $dw = $box->getWidth();
     $dh = $box->getHeight();
     $box->scale($ratio);
     $this->assertEquals(round($dw * $ratio), $box->getWidth());
     $this->assertEquals(round($dh * $ratio), $box->getHeight());
 }
Example #2
0
 /**
  * Load Part Of gd canvas from file
  *
  * <b>Note :</b>
  * This method will not check if the coordinat is valid coordinate for the
  * resource and it won't check the Dimension either.
  *
  * @param string      $file
  * @param \Jaguar\Box $box
  *
  * @return \Jaguar\Format\Gd
  *
  * @throws \InvalidArgumentException
  * @throws \Jaguar\Exception\CanvasCreationException
  */
 public function partFromFile($file, Box $box)
 {
     $this->isValidFile($file);
     $this->assertGdFile($file);
     $x = $box->getX();
     $y = $box->getY();
     $width = $box->getWidth();
     $height = $box->getHeight();
     $result = @imagecreatefromgd2part($file, $x, $y, $width, $height);
     if (false == $result) {
         throw new CanvasCreationException(sprintf('Faild To Create The Part "%s" Of The Gd Canvas From The File "%s"', $file, (string) $box));
     }
     $this->setHandler($result);
     return $this;
 }