{"id":17656433,"url":"https://github.com/mjakeman/zig-animate","last_synced_at":"2025-03-30T09:43:57.858Z","repository":{"id":220561015,"uuid":"751966476","full_name":"mjakeman/zig-animate","owner":"mjakeman","description":"Animation, interpolation, and sequencing library for zig.","archived":false,"fork":false,"pushed_at":"2024-02-03T04:20:37.000Z","size":25,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T20:19:48.011Z","etag":null,"topics":["animation","animation-library","interpolation","zig","zig-library"],"latest_commit_sha":null,"homepage":"","language":"Zig","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/mjakeman.png","metadata":{"files":{"readme":"README.md","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}},"created_at":"2024-02-02T18:07:34.000Z","updated_at":"2024-09-21T23:35:28.000Z","dependencies_parsed_at":"2024-02-02T19:27:16.103Z","dependency_job_id":"ae7aaef5-41ff-4448-8286-a7e80ba32c07","html_url":"https://github.com/mjakeman/zig-animate","commit_stats":null,"previous_names":["mjakeman/zig-animation"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjakeman%2Fzig-animate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjakeman%2Fzig-animate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjakeman%2Fzig-animate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjakeman%2Fzig-animate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mjakeman","download_url":"https://codeload.github.com/mjakeman/zig-animate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246301954,"owners_count":20755512,"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","animation-library","interpolation","zig","zig-library"],"created_at":"2024-10-23T14:32:31.673Z","updated_at":"2025-03-30T09:43:57.834Z","avatar_url":"https://github.com/mjakeman.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zig-animate\nA property animation library in Zig.\n\n## Demo 1: Property Interpolation\nFull demo code in [`animator.zig`](src/animator.zig).\n\n```zig\nconst start = Vec2{ .x = 0, .y = 0 };\nconst end = Vec2{ .x = 1, .y = 1 };\n\nconst anim = Animator(Vec2).init(start, end, EaseInCubicVec2);\n\n// 2D Cubic Easing\ntry std.testing.expectEqual(Vec2{ .x = 0.015625, .y = 0.015625 }, anim.eval(0.25));\ntry std.testing.expectEqual(Vec2{ .x = 0.125, .y = 0.125 }, anim.eval(0.5));\ntry std.testing.expectEqual(Vec2{ .x = 0.421875, .y = 0.421875 }, anim.eval(0.75));\ntry std.testing.expectEqual(Vec2{ .x = 1, .y = 1 }, anim.eval(1));\n```\n\n## Demo 2: Sequencing\nFull demo code in [`sequencer.zig`](src/sequencer.zig).\n\nWe can animate a complex object:\n```zig\nconst TestObject = struct {\n    value: f32,\n    other_value: Vec2,\n\n    const Self = @This();\n\n    fn update(self: *Self, value: f32) void { ... }\n    fn update_other(self: *Self, other_value: Vec2) void { ... }\n}\n```\n\nSequencing multiple property animations:\n```zig\nvar testObj: TestObject = undefined;\ntestObj.value = 30;\ntestObj.other_value = Vec2{ .x = 10, .y = 10 };\n\n// Go from 30 to 50 over 80 frames\nconst valueAnim = animator.Animator(f32).init(30, 50, curves.EaseInCubic);\nconst valueEvent = Event.create_transition(TestObject, f32, \u0026testObj, \u0026valueAnim, 80, TestObject.update);\n\n// Go from (10, 10) to (6, 4) over 65 frames\nconst otherValueAnim = animator.Animator(Vec2).init(Vec2{ .x = 10, .y = 10 }, Vec2{ .x = 6, .y = 4 }, EaseInCubicVec2);\nconst otherValueEvent = Event.create_transition(TestObject, Vec2, \u0026testObj, \u0026otherValueAnim, 65, TestObject.update_other);\n\n// Create a sequencer\nvar sequencer = Sequencer.init(TestAllocator);\nsequencer.add_event(0, valueEvent);\nsequencer.add_event(0, otherValueEvent);\n\n// Move the sequencer forward\nsequencer.tick(10);\n\n// Check the values\nconst expectedVal = curves.EaseInCubic(30, 50, 10.0 / 80.0);\ntry std.testing.expectEqual(expectedVal, testObj.value);\n\nconst expectedVector = EaseInCubicVec2(Vec2{ .x = 10, .y = 10 }, Vec2{ .x = 6, .y = 4 }, 10.0 / 65.0);\ntry std.testing.expectEqual(expectedVector, testObj.other_value);\n```\n\n## Key Concepts\nThe three files in this library are:\n * `animator.zig`: Contains Animators, which are objects that animate over a given property. You have one animator per property, so a location/rotation/scale animation might have `locationAnim: Animator(Vec3)`, `rotationAnim: Animator(Quat)`, `scaleAnim: Animator(Vec3)` (respectively).\n * `sequencer.zig`: Allows for Actions (one-off event) and Transitions (ongoing event) to be scheduled and run. You have one sequencer per project/module/grouping of animations.\n * `curves.zig`: A collection of interpolation functions for f32. See the `animator.zig` class for an easy example of how to create higher dimension interpolation functions (e.g. for Vector2/3/4/etc).\n\n## Examples\nIn each source file, there are fully-commented tests demonstrating some key patterns.\n\nFor example, see [sequencer.zig](/src/sequencer.zig).\n\n## Building\nStandard Zig library:\n```\nzig build\nzig build test --summary all\n```\n\n## About\nThis repo is a mirror of the in-tree animation library from my personal game engine project. As such, this library is actively (albeit infrequently) maintained.\n\n### Contributions\nContributions are welcome, although keep in mind the library scope is intentionally small.\n\n### Licence\nMIT Licensed - do what you want!","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjakeman%2Fzig-animate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmjakeman%2Fzig-animate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjakeman%2Fzig-animate/lists"}