Tatlap

A texture atlas packer library/CLI tool.
I know there are a lot of these out there, but I didn't find one that did everything I wanted it to:

I also wanted a project to learn Rust with, and making a command-line tool a perfect candidate.

Example usages: ```

This will create out.bin, out.txt, and out4.png

tatlap sprite1.png sprite2.png sprite3.png

You can specify the output prefix

tatlap --out sprites data/*.png

If you have a lot of images to pack you can put their names in a file

tatlap --file listofsprites.txt

Or pass them in standard input

cat listofsprites.txt | tatlap --stdin

You can also load images from a texture atlas you created previously:

tatlap --atlas out newsprite.png The `.txt` output file contains locations of the packed sprites. For example: 4 459 638 45 37 69 53 192 192 ```

The .bin output file contains the same data as the .txt output, but contains the values in serialized in a binary file. The first value (bytes per pixel) is a single byte, but the others are 16-bit unsigned integers (in little endian), so each image takes 17 bytes.

How you use the .txt and .bin is up to you; I find the .bin more useful for loading the sprites. Here is an example of how to would load it in C: ``` C FILE* fp = fopen("out.bin"); uint8t bpp; fread(&bpp 1, 1, fp); uint16t d[8]; fread(&xywh, 2, 8, fp); // Note that this won't work on bit-endian systems

// Extract the sprite based on d[0-4]

// Calculate where to draw the sprite centered on x and y // x - half uncropped width + cropped offset int drawx = x - d[6]/2 + d[4]; int drawy = y - d[7]/2 + d[5]; ```