Documentation
¶
Overview ¶
Package anim contains primitives for animation.
The core of the package is the Playable interface, which just represents a series of keyframes. What is at each keyframe is completely abstract and generic. For example, it could be a row/column pair indexing into a tilesheet, or it could be point on a parametric curve.
The package provides several wrappers for a Playable to generically modify its behavior, such as:
- Reversed, which reverses the order of the keyframes.
- Delayed, which inserts additional frames between each keyframe.
- PingPonged, which plays the keyframes in reverse order after playing them forward once.
These wrappers compose with one another. This means that an animation's keyframes can generally be separated from how they're actually played back.
Player is a type which can actually play back a Playable, expressed loosely as a pull iterator (which is more flexible in, for example, game engine contexts).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Delayed ¶
Delayed is a wrapper type that represents an animation with additional delays inserted between frames.
type PingPonged ¶
PingPonged is a wrapper type that represents a reversed animation.
func PingPong ¶
func PingPong[A Playable[T], T any](anim A) PingPonged[A, T]
PingPong causes the animation to ping pong (proceed forward, then backward) before completing.
type Playable ¶
type Playable[T any] interface { // At returns the value at the i'th keyframe. At(i int) T // Len returns the number of keyframes. Len() int }
Playable is an interface that describes an animation in terms of keyframes.
Really, it just describes any finite sequence.
type Player ¶
type Player[T any] struct { // contains filtered or unexported fields }
Player plays back an animation.
Really, it is a pull iterator that produces values from a finite sequence.
func (*Player[T]) Current ¶
func (p *Player[T]) Current() T
Current returns the value of the current frame in the animation.
func (*Player[T]) Loop ¶
Loop begins playing back the provided animation. The animation will loop forever.
This immediately overrides any current animation playing.