Lilt
A simple, dependency free library for running interruptable, transition based animations as a function of time.
This library only implements animations & would be most useful along with a GUI library that can do GUI things (like iced).
Getting Started
Define
Embed the state you want to animate in an Animated struct.
When you initialize your view state - define the initial state & configure the animation to your liking.
let mut state = MyViewState ;
Transition
When your state needs an update, call the transition function on your animated state, passing the current time.
let now = now;
state
.animated_toggle
.transition;
Render
While rendering a view based on your state - use the animate function on your state to get the interpolated value for the current frame.
let now = now;
// Use the animated float for something like width, height, offset
let animated_width = self.animated_toggle.animate_bool;
// Or add an `Interpolable` implementation to an object of your choice, like a color
let animated_color = self.animated_toggle.animate_bool;
// Sometimes `animate` or `animate_if_eq` can be better fits, depending on the wrapped type
let animated_width = self.animated_enum.animate;
let animated_opacity = self.animated_enum.animate_if_eq