A minimal Lua library for tweening (interpolating) numeric values in tables with various easing functions.
tween.lua is a small Lua library for tweening, which is the process of smoothly interpolating numeric values in tables over time. It enables developers to create animations, transitions, and visual effects by gradually changing properties like position, color, or volume. The library is inspired by jQuery's animate method and includes a variety of easing functions to control the animation's pace.
Lua developers, particularly those working on games with engines like LÖVE, or anyone needing lightweight animation and interpolation in Lua projects.
Developers choose tween.lua for its minimal interface, extensive built-in easing functions, and flexibility—it works with any time unit and supports custom easing. It's a pure Lua solution with no dependencies, making it easy to integrate into existing projects.
Tweening/Easing/Interpolating functions for lua. Inspired on jQuery's animate method.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
The interface is straightforward with just `tween.new()` for creation and `update()` for progression, making it easy to integrate into existing Lua codebases without a steep learning curve.
Comes with 45 built-in easing functions, including variants like bounce and elastic, as detailed in the easing table, allowing for natural and varied motion effects out-of-the-box.
Allows developers to define custom easing functions, enabling specialized interpolation for unique animations, as shown in the example using LÖVE's Bezier curves.
Works on deeply-nested subtables, so you can animate complex data structures like color arrays without flattening, as demonstrated in the fade example.
Provides `set()` and `reset()` methods for precise control over tween progression, including playing animations backwards, as highlighted in the demo and interface sections.
Lacks native support for chaining or grouping tweens, requiring manual code to manage sequences or parallel animations, which can be cumbersome for complex workflows.
Only animates numeric values in tables, so properties like strings or custom objects cannot be directly interpolated, limiting its use for non-numeric animations.
Does not define time units (e.g., seconds or milliseconds), so developers must consistently pass `dt` in the same unit, risking errors if time scaling is mismatched, as warned in the gotchas.
The README does not mention robust error checking for invalid inputs, so incorrect usage, such as mismatched subject-target keys, might fail silently or cause unpredictable behavior.