Appearance
Raylib
Packrat writes one C header for all pages. It includes functions to load the images, look up frames, and draw them with their trim offsets. Include raylib.h before the generated header. Create a graphics context before loading the atlas.
c
#include "raylib.h"
#include "atlas.h"
void draw_example(void) {
Packrat_atlas atlas = {0};
if (!packrat_load(&atlas, &packrat_atlas_definition, "assets")) return;
const Packrat_frame *frame = packrat_find(&atlas, "player", -1);
// Between BeginDrawing() and EndDrawing():
packrat_draw(&atlas, frame, (Vector2){400, 300}, 0,
(Vector2){2, 2}, WHITE);
packrat_unload(&atlas); // Before closing the graphics context
}| Helper | Use |
|---|---|
packrat_load(atlas, definition, directory) | Load page images; return false on failure |
packrat_unload(atlas) | Release textures |
packrat_frame_at(atlas, index) | Find a frame by its position in the frame list |
packrat_find(atlas, name, index) | Frame by name; negative index selects first |
packrat_find_animation(atlas, name) | Return frames in order and their count |
packrat_draw(atlas, frame, position, rotation, scale, tint) | Draw a frame; a negative scale mirrors it |
A failed lookup returns NULL. The generated definition is named packrat_<stem>_definition: for example, characters.h uses packrat_characters_definition. You can include several generated Raylib headers; include guards prevent duplicate shared helper definitions.
Frame fields include page, source, original_size, offset, and index.
The draw position is the center of the original, untrimmed frame. Rotation is measured in degrees.
See Sources and outputs for frame names, trimming, and effect maps.