/** * * @param Box $box */ private function mapSection($x, $y) { $ss = $this->mPanel->getSectionSize(); $ts = $this->mPanel->getTileSize(); $sw = $ss->width / $ts->width; $sh = $ss->height / $ts->height; $box = new Box(new Point(($x + 1) * $sw, ($y + 1) * $sh), new Point($x * $sw, $y * $sh)); $section = Image::create($ss->width, $ss->height); if ($section === false) { throw new \Exception(); } $lands = $this->mWorld->findAllTileContainedInBox($box); krsort($lands); foreach ($lands as $land) { $left = ($land->longitude - $box->left) * $ts->width; $bottom = ($land->latitude - $box->bottom) * $ts->height; $t = $this->mWorld->getLandType($land->color); $image = $this->mPanel->getTileImage($t); $bottom += $image->height - $ts->height; $section->drawImage($left, $section->height - $bottom, $image); } $path = $this->mDirectory . '/' . $this->mPanel->getName() . '/' . base_convert($x, 10, 36) . '_' . base_convert($y, 10, 36) . '.png'; @mkdir(dirname($path), 0777, true); $section->save($path); }
/** * * @param TilePanel $panel * @return Cartographer */ public function findOneByTilePanel(TilePanel $panel) { return $this->findOneByTilePanelName($panel->getName()); }