# Autotile Generator (blob 47 and Wang 16 rules) > Turn a terrain grid into autotiled tile ids, a TMX map and a PNG preview. Draw terrain as # and . rows and choose the 47-tile blob set or the 16-tile Wang edge or corner set. The rule engine picks each tile variant from its neighbours and returns tile indices, a Tiled TMX map, a rendered PNG and merged collision rectangles. Part of usefulweb.app (https://usefulweb.app/). Part of [Flipline](https://flipline.usefulweb.app/) (ownerApp: flipline). Results are deterministic calculations from the inputs and the listed assumptions; the API returns exactly what the web page shows. ## Use it - Human interface: https://fliplineautotilegenerator.usefulweb.app/ (interactive tool at https://fliplineautotilegenerator.usefulweb.app/tool) - JSON API: POST https://fliplineautotilegenerator.usefulweb.app/api/v1/calculate with a JSON object of inputs (schema: https://fliplineautotilegenerator.usefulweb.app/api/v1/tool) - OpenAPI: https://fliplineautotilegenerator.usefulweb.app/openapi.json - MCP (Streamable HTTP): https://fliplineautotilegenerator.usefulweb.app/mcp - tool `flipline_autotile_generator` ## Inputs - terrain (textarea): Terrain rows (# = terrain, . = empty) - mode (select): Rule set - tileSize (integer): Tile size (px) - outside (select): Cells beyond the grid - orientation (select): Map orientation - encoding (select): TMX layer encoding - tileset (file): Own tileset PNG (optional; tiles in slot order unless mapped) - mapping (text): Slot → tile mapping (optional; 47 or 16 numbers, −1 = missing) ## Method - Blob (47): the 8-neighbour mask uses N=1, NE=2, E=4, SE=8, S=16, SW=32, W=64, NW=128; a corner only counts when both adjacent edges are terrain, which leaves 47 distinct masks. Flipline slot order is the ascending mask value (slot 0 = mask 0, slot 46 = mask 255). - Wang edge (16): mask N=1, E=2, S=4, W=8 of terrain cells. Wang corner (16): a vertex is terrain when any of its four cells is terrain; each cell’s mask is NE=1, SE=2, SW=4, NW=8, so terrain gains a one-cell ring of corner pieces. The slot equals the mask. - Missing variants fall back to the same edges without corners (blob), then to the full-terrain tile, and are listed as warnings. Wang sets are exported to Tiled as mixed, edge or corner sets with matching wangids. - The built-in tileset is drawn procedurally (original artwork) with a full-tile collision rectangle per tile (corner tiles: the covered quadrants), so collision rectangles are merged by greedy meshing. - Flipline’s Tilemap Desk autotile brush uses the same rule engine; painting the same cells there gives the same tile ids.