keyframe
A simple library for animation in Rust
Features
- Several easing functions, including user-defined Bézier curves (like CSS cubic-bezier) and keyframable curves
- Animation sequences (like CSS @keyframes)
- mint integration for 2D/3D/4D support (points, rectangles, colors, etc)
Usage
Tweening between two values is done with keyframe::ease(function, from, to, time). from and to can be any type that implements CanTween, such as f64 or mint::Vector2, while time needs to be a floating-point value between zero and one. function specifies the transition between from and to and is any type that implements EasingFunction.
keyframe::AnimationSequence can be used to create more complex animations that keep track of keyframes, time, etc. You can create animation sequences with the keyframes![...] macro, from an iterator or from a vector.
Examples
An example visualizer is included in examples/. Run cargo run --example visualizer --release to start it. (ggez is really slow in debug mode!)
Tweening:
use ;
Animation sequences:
use ;
Custom structures:
use Point2;
// This macro works with any structure as long as it only consists of types that implement "CanTween"
use CanTween;
// Also works with unnamed structures
;