Appearance
Pure C
Packrat writes C99 frame data for your own image-loading and drawing code. Each page has a header and an image. Filenames are numbered when the atlas has several pages.
c
typedef struct PackratFrame {
const char *name;
uint32_t x, y, width, height;
uint32_t original_width, original_height;
int32_t offset_x, offset_y;
int32_t index;
uint8_t rotated;
} PackratFrame;Include atlas.h. For the first page, use packrat_sheet_1_image, packrat_sheet_1_frames, and packrat_sheet_1_frame_count. Page suffixes start at 1. packrat_sheet_N_width and packrat_sheet_N_height give the dimensions of page N.
Use x, y, width, and height to select the frame's pixels from its page image. offset_x is measured from the left of the original frame; offset_y is measured from the bottom. If your drawing code measures from the top, use original_height - height - offset_y for the vertical offset.
To build an animation, group frames by name and sort them by index. Static images have an index of -1.
The Raylib, SDL2, and SDL3 formats add loaders and draw helpers. See Sources and outputs for frame names, trimming, and effect maps.