Autotile Generator (blob 47 and Wang 16 rules)
Turn a terrain grid into autotiled tile ids, a TMX map and a PNG preview.
Try an example: Two islands with a lake (blob 47) · A cave edge with Wang edge tiles and zlib layers · Isometric pond with Wang corner tiles
How it works
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.
- 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.
Sources
Part of Flipline
-
Flipline Drawing, storyboards & animation
A few drawings. A little life. Make a flipbook in your browser.
How to use the Autotile Generator
Turn a grid of terrain cells into the right blob or Wang tile variant for every cell, with a Tiled TMX map, a PNG preview and merged collision rectangles.
What it is for
Hand-placing terrain edges is tedious: every grass cell needs the variant that matches its neighbours, with an outer edge here, an inner corner there and a lone island somewhere else. Autotiling automates this. You mark where the terrain is, and a rule table picks the correct tile for each cell.
The generator supports the three common rule sets. Blob (47 tiles) looks at all eight neighbours, with a corner only counting when both adjacent edges are terrain. Wang edge (16 tiles) looks at the four sides. Wang corner (16 tiles) works on the corners between cells. You get tile indices, a TMX file for Tiled, a PNG preview and collision rectangles. Flipline's Tilemap Desk autotile brush uses the same rules, so painting the same cells there gives the same tile ids.
Without your own tileset it draws an original procedural meadow tileset. It does not generate terrain shapes for you; you draw them as text rows.
Worked example
The built-in example draws two islands, a lake and a few platforms on a 20 × 12 grid with # for terrain. With the blob rules it reported: "Autotiled 87 terrain cells with the blob (47 tiles) rules: 87 tiles placed, 17 merged collision rectangles." In the tile grid, the cells above the lake read 36, which is slot 36: mask 199 = N + NE + E + W + NW. The lake removes the south edge, so the two southern diagonals no longer count either.
A custom run used a small ring (.####. / .#..#. / .####.) with Wang edge rules and an incomplete mapping, 0,1,2,3,4,5,-1,7,…,15, where slot 6 is missing. The result placed 10 tiles and warned: "1 variant is missing from the tileset (slot 6, mask 6); a fallback tile was used." Mask 6 is east + south, the top-left corner of the ring, so that corner fell back to the full-terrain tile.
A third run, a 5 × 3 ring with Cells beyond the grid: Terrain, gave 44 in the top-left cell: mask 247, everything except the south-east diagonal, which is the hole.
How to read the result
- Metrics: grid size, terrain cells, tiles placed, missing variants and merged collision rectangles.
- Chosen tile per cell: local tile ids in grid order, with
.for empty cells. For corner rules, cells next to terrain also get corner pieces, so more tiles are placed than there are terrain cells. - Downloads: rendered PNG, TMX with a Wang set (mixed, edge or corner) so Tiled's terrain brush keeps working, and an editable Flipline tilemap project.
Tips and common mistakes
- Slot order is Flipline's: blob slots follow the ascending mask (N=1, NE=2, E=4, SE=8, S=16, SW=32, W=64, NW=128); edge and corner slots equal their mask. Lay out your own tileset in that order or give a mapping.
- Use −1 in a mapping for variants you have not drawn yet. Blob falls back to the same edges without corners, then to the full tile.
- Cells beyond the grid: Terrain is right for rooms whose walls continue off-screen.
- With corner rules, a single empty cell surrounded by terrain closes up. Leave holes at least two cells wide.
- Isometric output projects the meadow tiles onto diamonds and halves the tile height.
FAQ
Why 47 tiles and not 256?
With eight neighbours there are 256 combinations, but a corner only shows when both sides next to it are terrain. That leaves 47 distinct cases.
Can I use my own tileset?
Yes. Upload a PNG with the tiles in slot order, or add a mapping with one tile number per slot.
Are collisions included?
The built-in tiles have full-tile collision rectangles, so the result merges solid cells into rectangles. For your own PNG, add collision shapes in Tilemap Desk.
Does it work in Tiled afterwards?
Yes. The TMX includes the tileset, tile properties and a Wang set, so Tiled's terrain brush can keep editing the map.
Guide last updated:
For scripts and AI agents
- JSON API:
POST https://fliplineautotilegenerator.usefulweb.app/api/v1/calculate(same calculation as this page) - Interface description: OpenAPI 3.1 · AI guide: llms.txt
- MCP server (Streamable HTTP):
https://fliplineautotilegenerator.usefulweb.app/mcp· tool nameflipline_autotile_generator
Example request
curl -s -X POST https://fliplineautotilegenerator.usefulweb.app/api/v1/calculate \
-H 'content-type: application/json' \
-d '{"terrain":"....................\n..######......###...\n.########....#####..\n.###..###....##.##..\n.########.....###...\n..######............\n....##.....#######..\n....##.....#######..\n..........##.....#..\n.#####.....#######..\n.#####..............\n....................","mode":"blob47","tileSize":16,"outside":"empty","orientation":"orthogonal","encoding":"csv","mapping":""}'