Hey there!
Say I’ve got an object defined as a polygon aligned to the tilegrid, is there a way to fill it (or an associated Tile Layer) up with a tileset?
I’ve tried selecting the object in the Object tab, going to Layers tab, then clicking fill on the selection, but it fills the entire map, instead of just the selected object’s polygon.
Would this be something I could write in a script? I took a look at the Tileset docs and it seemed more like manipulating the tileset itself, rather than using it, although the tile-rectangle example uses the Tilemap which looks like it could also be a tileset.
In short, I’m wondering if I can somehow fill a selection (or ideally a selected object’s custom polygon) with a tileset. If not, is there some way I can write a custom extension to implement this for me?
edit: the tile-rectangle.js gets pretty close in action. If I can figure out how to get it to use the tileset instead of the selected tiles, and then also floodfill, I’ll be lookin’ good
These are called Wangs, and I appear to be close: tiled.mapEditor.tilesetsView.currentTileset.wangSets
lists one that hopefully contains what I want to use. It looks like it’s basically a ‘layer’ of values for which color each tile in the tileset is painted. Then you can call myWangSet.wangId(tileFromMyTileset)
to get an array of values to figure out which color its painted.
I don’t see any way to call something to deal with wangs, so I’ll have to write that bit myself then, checking for neighboring tiles’ wang id and choose the current tile based on that.