BASH script to build a texture atlas for small/medium web sites/games. Requires ImageMagick.
Just run
$ ./mkatlas img/*
which will create atlas.png and outputs the corresponding sprite regions in JSON format:
var atlas={
first:{x:298,y:0,w:35,h:22},
second:{x:254,y:0,w:44,h:33},
...
}
Alternatively you may use just markers in your JavaScript to insert the frame data in place. This way you wouldn't have to have a extra atlas object and wouldn't need to do any additional mapping. For example:
var obj = {
name: "Jim",
frame: {/*first*/x:0,y:0,w:0,h:0},
live: 100 };
This file may be patched with patchatlas like this:
$ ./mkatlas img/* | ./patchatlas index.html
There are a few variables for fine tuning. Just put them before invocation, e.g.:
$ ATLAS=atlas.jpg ./mkatlas img/*
Maximum width/height of atlas. Default is 2048.
Padding around sprites. Default is 0.
File name (and image format) of atlas image.