Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct { Duration time.Duration // The total duration of the tween. Framerate int // The number of tween data points per second (defaults to 60 fps - like the real gamers use). Transition TransitionFunc // Transition calculates the transition curve for the tween. Updater Updater // Updater updates the tween values for each frame. // contains filtered or unexported fields }
Engine runs a tween relying on transitioner and updater.
type Frame ¶
type Frame struct { Completed float64 // Completed is the percentage 0.0 - 1.0 of elapsed time. Transitioned float64 // Transitioned is the percentage 0.0 - 1.0 of transition between start and end values of the tween. Index int // Index is the current frame index Elapsed time.Duration // Elapsed is the current elapsed time in the tween. }
Frame captures information about the current "frame" of a tween transition.
type TransitionFunc ¶
TransitionFunc calculates the percentage of the transition between the start and end values based tween (elapsed time) completion status. For example, a linear tween simply has a 1:1 ratio between completed and transition percentages and returns the completed value unchanged. An "ease in" transition may create a logorithmic relationship between the completion time and transition value for the first third, then a linear relationship for the remainder.
type Updater ¶
type Updater interface { // Start signals the beginning of a tween and is sent before the tweening // begins. Start may be used to setup or pre-calculate updates. // // framerate is the number of frames per second in the tween // frames is the total number of frames that be generated // frameTime is the duration for each frame // runningTime is the total duration for the entire tween Start(framerate, frames int, frameTime, runningTime time.Duration) // Update receives information about the current Tween Frame and should be // used to update output or state. Update(Frame Frame) // End signals the end of the tween and is called after all updates. // End may be used to clean up resources (e.g. update channels). End() }
Updater is the interface for updating the current value as it tweens between start and end values of a Tween.