Transforms a spritesheet
Rust 100%

README.md

make-spritesheet #

A small tool which copies an image into a grid with coloured padding, and can reconvert the padded grid into an unpadded grid with different flags.

I wrote this so that I can edit my game spritesheet in Pixelorama as a single image with clear markings per sprite, and remove the padding when used as a game asset. The padding also helps with drawing multitile sprites.

Examples #

Clone the repo, then run cargo run -- -help to see the options provided by clap.

To produce a grid with 10px white padding:

cargo run -- -i lily.png -o example-output.png -g 10 --htiles 4 --vtiles 4: Single lily

Lily grid

Opacity is respected; using an "empty" png like blanktile.png can be used to make a blank spritesheet.

To convert this grid into a new one with 3px magenta padding:

cargo run -- -m -i example-output.png -o example_reduced_padding.png --orig-gap 10 --orig-tilesize-x 16 --orig-tilesize-y 16 -g 3 --gapcolor "#ff00ff" --htiles 4 --vtiles 4

Magenta lily grid

This requires specifying the tiles and tilesize in pixels in the grid provided, the program does not attempt to guess these values.

The padding with -g can be set to 0, in which case a gap colour would have no effect.o

For my spritesheet in the repo, the command to reduce the padding is:

cargo run -- -m -i spritesheet_100x100.png -o spritesheet_reduced.png --orig-gap 1 --orig-tilesize-x 12 --orig-tilesize-y 12 -g 0 --htiles 100 --vtiles 100