{"id":21725704,"url":"https://github.com/atomicptr/anima","last_synced_at":"2026-01-08T09:52:48.589Z","repository":{"id":264733427,"uuid":"784865253","full_name":"atomicptr/anima","owner":"atomicptr","description":"A 2D animation library for Odin","archived":false,"fork":false,"pushed_at":"2024-07-18T14:14:18.000Z","size":278,"stargazers_count":27,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T02:49:56.600Z","etag":null,"topics":["2d","2d-graphics","animation","animation-library","animations","game-dev","game-development","gamedev","odin-lang","odin-lib","odin-libraries","odin-programming-language","raylib","raylib-odin"],"latest_commit_sha":null,"homepage":"","language":"Odin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atomicptr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"atomicptr","buy_me_a_coffee":"atomicptr"}},"created_at":"2024-04-10T17:59:20.000Z","updated_at":"2025-03-17T18:12:53.000Z","dependencies_parsed_at":"2024-11-26T03:31:41.157Z","dependency_job_id":null,"html_url":"https://github.com/atomicptr/anima","commit_stats":null,"previous_names":["atomicptr/anima"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Fanima","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Fanima/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Fanima/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atomicptr%2Fanima/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atomicptr","download_url":"https://codeload.github.com/atomicptr/anima/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246731143,"owners_count":20824511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["2d","2d-graphics","animation","animation-library","animations","game-dev","game-development","gamedev","odin-lang","odin-lib","odin-libraries","odin-programming-language","raylib","raylib-odin"],"created_at":"2024-11-26T03:19:56.894Z","updated_at":"2026-01-08T09:52:48.541Z","avatar_url":"https://github.com/atomicptr.png","language":"Odin","readme":"# anima\n\nA 2D animation library for Odin\n\nInspired by the LÖVE library [anim8](https://github.com/kikito/anim8)\n\n## Compatibility\n\nThis library is implemented to be renderer agnostic, however there is a raylib implementation available in ``anima/anima_raylib``.\n\n## Installation\n\nCopy the ``anima`` directory somewhere into your project as this is the package, feel free to delete the sub directories inside that you do not need like ``anima/anima_raylib`` if you for instance do not use raylib.\n\n(You might also want to use git submodules)\n\n## Usage\n\nCheck out one of the examples:\n\n- [anim8 1945 example](./examples/anim8_1945/main.odin) (port of the anim8 demo)\n- [cat fighter fsm](./examples/cat_fighter_fsm) - Animations with a finite state machine\n\n### Simple Example\n\n```odin\npackage main\n\n// assuming you have the package located in a directory adjacent to the current package\nimport \"anima\"\nimport \"anima/anima_raylib\"\nimport rl \"vendor:raylib\"\n\nmain :: proc() {\n  rl.InitWindow(800, 600, \"Simple Example\")\n  defer rl.WindowClose()\n\n  rl.SetTargetFPS(60)\n\n\n  image := rl.LoadImage(\"path/to/image.png\")\n  texture := rl.LoadTextureFromImage(image)\n  defer rl.UnloadTexture(texture)\n  rl.UnloadImage(image)\n\n  // first we need to define our grid\n  grid := anima.new_grid(32, 32, texture.width, texture.height)\n\n  animation := anima.new_animation(\n    // here we specify we want column: 0-7 in row: 0\n    anima.grid_frames(\u0026grid, \"0-7\", 0),\n    // and the animation speed is 0.1s\n    0.1,\n  )\n  // don't forget to clean up after yourself\n  defer anima.destroy_animation(animation)\n\n  for !rl.WhileWindowShouldclose() {\n    dt := rl.GetFrameTime()\n\n    // update the animation before drawing\n    anima.update(animation, dt)\n\n    rl.BeginDrawing()\n    rl.ClearBackground(rl.RAYWHITE)\n\n    // and finally draw the animation\n    anima_raylib.draw(animation, texture, 100, 100)\n\n    rl.EndDrawing()\n  }\n}\n```\n\n## Documentation\n\n### Grids\n\nGrids exist to make it as easy as possible to quickly define animations using rectangles of the same size.\n\nYou can define a grid like this:\n\n```odin\nanima.new_grid(\n  frame_width,  // the width of the frame\n  frame_height, // the height of the frame\n  image_width,  // the width of the image (or part of said image) from which we get the frame\n  image_height, // the height of the image (or part of said image) from which we get the frame\n  left,         // (optional) starting x positon of our grid, this is used to define multiple grids within a single file\n  top,          // (optional) starting y position of our grid, this is used to define multiple grids within a single file,\n  border,       // (optional) this allows you to define gaps between images\n) -\u003e Grid {\n```\n\n![](./.github/images/grid_example.png)\n(Took this explanation from the anim8 repo)\n\nTo get frames from a grid you need to call the ``anima.grid_frames`` procedure\n\n```odin\nanima.grid_frames(\n  grid_ptr,                // a pointer to our grid\n  column_interval_range_0, // the defined column range of our animation\n  row_interval_range_0,    // the defined row range of our animation\n  column_interval_range_1, // the defined column range of our animation\n  row_interval_range_1,    // the defined row range of our animation\n  column_interval_range_2, // the defined column range of our animation\n  row_interval_range_2,    // the defined row range of our animation\n  // .... this is a variadic function so this can take as many arguments as you want\n)\n\n### Animations \n\nAnimations are a group of frames that change after a set duration\n\n```odin\nanimation := anima.new_animation(\n  frames,      // the frames to play, this should be supplied using grids\n  duration,    // the duration each frame will take until the next one will play\n  playing,     // (optional) is the animation playing? Default is true\n  oneshot,     // (optional) should the animation only play once? Default is false\n  on_finished, // (optional) a callback that will be called every time the current animation has finished\n)\n```\n\nnew_animation returns a pointer to an animation so you also have to call \n\n```odin\nanima.destroy_animation(animation)\n```\n\nafter you are done with it.\n\nThe animation structs also has a flip\\_h and flip\\_v property in case you want to flip the sprite.\n\n## Assets\n\n- examples/anim8_1945/assets/1945.png - [Widgetworx Spritelib](http://www.widgetworx.com/widgetworx/portfolio/spritelib.html)\n- examples/cat_fighter_fsm/assets/cat_fighter.pn - [dogchicken from opengameart.org](https://opengameart.org/content/cat-fighter-sprite-sheet)\n\n## License\n\nMIT\n","funding_links":["https://github.com/sponsors/atomicptr","https://buymeacoffee.com/atomicptr"],"categories":["Libraries"],"sub_categories":["Gamedev"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicptr%2Fanima","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatomicptr%2Fanima","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatomicptr%2Fanima/lists"}