{"id":16122087,"url":"https://github.com/foxcapades/renpy-generated-animations","last_synced_at":"2025-04-06T11:41:30.702Z","repository":{"id":179027903,"uuid":"662733534","full_name":"Foxcapades/renpy-generated-animations","owner":"Foxcapades","description":"Demonstration and source for generating animations from a collection of frames.","archived":false,"fork":false,"pushed_at":"2023-07-31T17:22:57.000Z","size":4559,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-12T17:19:24.295Z","etag":null,"topics":["animation","renpy"],"latest_commit_sha":null,"homepage":"","language":"Ren'Py","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/Foxcapades.png","metadata":{"files":{"readme":"readme.adoc","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2023-07-05T19:10:22.000Z","updated_at":"2025-01-24T04:53:31.000Z","dependencies_parsed_at":"2023-07-30T18:23:18.605Z","dependency_job_id":"df426db7-4167-443d-8c64-505adae39a46","html_url":"https://github.com/Foxcapades/renpy-generated-animations","commit_stats":{"total_commits":29,"total_committers":1,"mean_commits":29.0,"dds":0.0,"last_synced_commit":"676088d92ab2037e5a37e14f0e52a9707a0b1fb3"},"previous_names":["foxcapades/renpy-generated-animation-demo","foxcapades/renpy-generated-animations"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foxcapades%2Frenpy-generated-animations","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foxcapades%2Frenpy-generated-animations/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foxcapades%2Frenpy-generated-animations/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Foxcapades%2Frenpy-generated-animations/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Foxcapades","download_url":"https://codeload.github.com/Foxcapades/renpy-generated-animations/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247478234,"owners_count":20945262,"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":["animation","renpy"],"created_at":"2024-10-09T21:09:21.693Z","updated_at":"2025-04-06T11:41:30.656Z","avatar_url":"https://github.com/Foxcapades.png","language":"Ren'Py","funding_links":[],"categories":[],"sub_categories":[],"readme":"= Generate Animations from Frames\n:source-highlighter: highlight.js\n:toc:\n\nThe source code and a demonstration of automatically generating an animation\nbased on png frames in a subdirectory of the game directory.\n\n== Why?\n\nIf you have ever constructed animations by doing the following, you quickly\nrealize how tedious it can be.\n\n[source, python]\n----\nimage tacos:\n    \"images/tacos/frame1\"\n    pause 0.2\n    \"images/tacos/frame2\"\n    pause 0.2\n    \"images/tacos/frame3\"\n    pause 0.2\n    \"images/tacos/frame4\"\n    pause 0.2\n    \"images/tacos/frame5\"\n    pause 0.2\n    \"images/tacos/frame6\"\n    pause 0.2\n    repeat\n----\n\nWhile this approach is fine if you have few frames or few animations, if you\nhave to construct an animation with many frames or a lot of animations, this\nquickly becomes a pain.\n\nInstead, for situations where the pause duration is the same between frames, we\ncan replace that tedium with a simple function call:\n\n[source, python]\n----\nimage tacos = generate_animation(\"images/tacos\", pause=0.2, looping=True)\n----\n\nIn the provided demonstration, we create an animation out of a 48 frame\nexplosion, which would be really hecking tedious to do manually.\n\n\n=== What about...?\n\nAnimations with variable framerates::\nIf your animation holds on some frames for longer than or shorter than others,\nthis is not the solution for you.  This will set the pause duration on all\nframes to the value given (or the default of `30` frames per second).\n\n\n== Usage\n\n. Download the link:https://github.com/Foxcapades/renpy-generated-animations/releases/latest[latest release].\n. Unzip it into your project directory (the directory above `game`).\n. Create a new directory inside your `game` directory to contain your animation\nframes.\n. Ensure your frames are named with an incrementing number (with an optional\ncommon prefix or a suffix).\n. Create your generated animation!\n+\n[source, python]\n----\nimage explosion = generate_animation(\"images/explosion\", fps=45)\n----\n\n\n== Functions\n\n`generate_animation`::\n+\nGenerates an animation from the png files in the given directory, in name order.\n+\nIt is advised that, to keep the ordering of frames correct, the files in the\ngiven directory are suffixed with an incrementing integer with one or more\npreceding zeros.  For example: `[ file01.png, file02.png, file03.png, ... ]` or\n`[ 01.png, 02.png, 03.png, ... ]`.\n+\n\n.Notes on filename suffix leading zeros...\n[%collapsible]\n====\nThe leading zeros are necessary due to the fact that sorting files by name will\nput `file10.png` _before_ `file2.png` as it will compare the `1` in `10` to the\n`2` and stop there.  However, with `file02.png` and `file10.png`, it will\ncompare the `0` in `02` to the `1` in `10` and stop there, putting them in the\ncorrect relative order based on that.\n\nThe number of preceding zeros necessary depends on the number of frames in your\nanimation, and the zeros are only necessary for filenames with a lesser number\nof digits than the max digit count for the last frame.\n\nFor example, if you have 10 frames, it would be advised that the numbers `0-9`\nbe prefixed with a single leading zero so the total digit width of the suffix\nnumber is always 2.\n\n[source]\n----\nfile01.png\n...\nfile10.png\n----\n\nIf you had 100-999 frames for your animation (whoa, nelly!) it would be advised\nthat you put 2 leading zeros before the numbers `0-9` and 1 leading zero before\nthe numbers `10-99` to keep the ordering correct.\n\n[source]\n----\nfile001.png\n...\nfile010.png\n...\nfile245.png\n----\n====\n+\n.Arguments\n--\n[cols=\"1m,1m,8\"]\n|===\n\n| directory\n| str\n| The directory containing the animation frames.  This path is relative to the\n  game directory.  For example, a path may look like:\n  \"images/animations/explosion\".\n|===\n--\n+\n.Keyword Arguments\n--\n[cols=\"1m,1m,8\"]\n|===\n| fps\n| int\\|float\n| Frames per second for the animation.  Incompatible with the `pause` keyword\nargument; setting both will cause an error.\n\nDefaults to `30`.\n\n| pause\n| float\n| How long to pause between each frame.  Incompatible with the `fps` keyword\nargument; setting both will cause an error.\n\nDefaults to `None`.\n\n| looping\n| bool\n| Whether or not the animation should loop.\n\nDefaults to `False`.\n\n| hold_last_frame\n| bool\n| Whether or not the animation should hold on the last frame or vanish after\ncompletion.\n\nDefaults to `False`.\n|===\n--\n\n\n== Credits\n\n* Original inspiration: link:https://www.reddit.com/r/RenPy/comments/vhgn1h/comment/id7frau/?utm_source=share\u0026utm_medium=web3x\u0026utm_name=web3xcss\u0026utm_term=1\u0026utm_content=share_button[Blue_Budgies on Reddit]\n* Explosion frames: https://www.pngegg.com/en/png-nvowz\n\n\n== License\n\nThis source code and project are released under the MIT license, which to\nparaphrase in a way that is not legally binding:\n\n* You can use it for free things\n* You can use it for paid things\n* You can modify it however you see fit\n* You can redistribute it as you see fit\n* Go nuts!\n\nFor a better breakdown of what the license actually means see:\nhttps://choosealicense.com/licenses/mit/\n\nI do ask that you credit me in some way, but if you don't I'm not gonna call the\nopen-source police on you.  If you do choose to credit me you can do so by\nproviding a link to my link:https://github.com/Foxcapades[GitHub], my\nlink:https://foxcapades.itch.io/[Itch.io], or just call me Foxcapades.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxcapades%2Frenpy-generated-animations","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoxcapades%2Frenpy-generated-animations","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxcapades%2Frenpy-generated-animations/lists"}