Documentation
¶
Overview ¶
Package tween provides caller-advanced Tween playheads for duration-based transitions.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Tween ¶
type Tween struct {
// contains filtered or unexported fields
}
Tween tracks elapsed time and applies an easing curve to normalized progress. Pass its progress to geom.Lerp or geom.Vector2.Lerp to interpolate values. The caller chooses the clock by supplying elapsed time to Tween.Update.
Copying a Tween copies its playback state. Copies share the curve and any state it captures; the curve should be pure so repeated reads agree.
The zero value is uninitialized: Update returns an error, Progress returns 0, IsComplete returns false, and Reset leaves it uninitialized.
Example ¶
tween, err := NewTween(time.Second, geom.EaseInQuad)
if err != nil {
fmt.Println(err)
return
}
weight, err := tween.Update(500 * time.Millisecond)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(geom.Lerp(0, 100, weight))
fmt.Println(tween.IsComplete())
Output: 25 false
func NewTween ¶
NewTween returns a Tween with the given duration and easing curve. It returns an error if duration is non-positive. A nil curve means geom.EaseLinear.
func (*Tween) IsComplete ¶
IsComplete reports whether the tween has reached its duration. Completion remains true until Tween.Reset, regardless of the curve's output.
func (*Tween) Progress ¶
Progress returns the current eased progress of the tween without advancing it. It evaluates the curve at elapsed time divided by duration. The result is not clamped, including at completion.