コード例 #1
0
 /**
  *
  * @return Image 
  */
 public function setImage($path)
 {
     $image = Image::createFromFile($path);
     if (!$image) {
         throw new \InvalidArgumentException();
     }
     if ($this->mWidth !== $image->width || $this->mHeight !== $image->height) {
         throw new \InvalidArgumentException();
     }
     $this->mImagePath = $path;
     return $this->mImage = $image;
 }
コード例 #2
0
 /**
  *
  * @param LandType $type
  * @return Image 
  */
 public function getTileImage(LandType $type)
 {
     if (!isset($this->mTiles[$type->id])) {
         $path = $this->mTileDirectory . '/' . $type->getImagePath();
         $image = Image::createFromFile($path);
         if ($image->height < $this->getTileHeight()) {
             throw new \Exception('Invalid tile image height. (' . $this->getTileHeight() . ')');
         }
         if ($image->width != $this->getTileWidth()) {
             throw new \Exception('Invalid tile image width. (' . $this->getTileWidth() . ')');
         }
         $this->mTiles[$type->id] = $image;
     }
     return $this->mTiles[$type->id];
 }