houmain / spright

An advanced sprite sheet packer and sprite annotator.
GNU General Public License v3.0
52 stars 10 forks source link

Ensure the lowest index duplicate is the one that is kept #8

Closed elegios closed 7 months ago

elegios commented 10 months ago

I'm looking into using spright to merge and deduplicate a bunch of tilesets for use in ldtk, which has a very simple notion of what a tileset is (one image for a tileset, one tileset per layer, tiles identified by position in image). Using spright is a bit overkill for this, but I want to use it for the more advanced features for other assets, so it seems nice to be consistent.

It seems that using rows packing (or columns I guess), a fixed width/max-width, deduplication, and no trimming should create a stable output, in the sense that adding a new input at the end of the configuration file shouldn't move previous tiles. Unfortunately this is only almost the case, because deduplication doesn't actually ensure that the same tile is kept. This PR changes that, making it so that duplicate_of_index <= index holds for all sprites.

I'm using this patch locally, but I figured it might be interesting for others as well.

houmain commented 7 months ago

Thank you very much for your valuable contribution!