ween

package
v0.0.0-...-e1c21c9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2019 License: Zlib Imports: 4 Imported by: 6

Documentation

Index

Constants

View Source
const (
	RepeatOnce     = 1
	RepeatInfinite = -1
)

Sets how many times the animation should be repeated.

Variables

This section is empty.

Functions

func ColorLerp

func ColorLerp(from, to gfx.Color, f float32) gfx.Color

func F32Lerp

func F32Lerp(from, to float32, f float32) float32

func IntLerp

func IntLerp(from, to int, f float32) int

func U16Lerp

func U16Lerp(from, to uint16, f float32) uint16

func U8Lerp

func U8Lerp(from, to uint8, f float32) uint8

func Vec2Lerp

func Vec2Lerp(from, to f32.Vec2, f float32) f32.Vec2

Types

type AnimState

type AnimState uint8
const (
	Waiting AnimState = iota
	Running
	Stopped
	Dispose
)

type Animation

type Animation struct {
	LoopType
	// contains filtered or unexported fields
}

维护动画的状态数据 底层动画系统,使用float作为单位 0-1

func (*Animation) Animate

func (anim *Animation) Animate(dt float32) (f float32)

动画核心算法

func (*Animation) Reset

func (anim *Animation) Reset()

type Animator

type Animator struct {
	// contains filtered or unexported fields
}

func (Animator) Dispose

func (am Animator) Dispose()

func (Animator) Forward

func (am Animator) Forward()

func (Animator) OnComplete

func (am Animator) OnComplete(cb EndCallback) Animator

func (Animator) OnUpdate

func (am Animator) OnUpdate(cb UpdateCallback) Animator

func (Animator) Reverse

func (am Animator) Reverse()

func (Animator) SetDuration

func (am Animator) SetDuration(d float32) Animator

func (Animator) SetFunction

func (am Animator) SetFunction(function ease.Function) Animator

func (Animator) SetRepeat

func (am Animator) SetRepeat(count int, loop LoopType) Animator

func (Animator) Stop

func (am Animator) Stop()

func (Animator) Valid

func (am Animator) Valid() bool

func (Animator) Value

func (am Animator) Value() (f float32)

type Callback

type Callback struct {
	UpdateCallback
	EndCallback
}

type ColorTween

type ColorTween struct {
	// contains filtered or unexported fields
}

A gfx.Color linear interpolation between a beginning and ending value. It use the Animator as the input.

func (*ColorTween) Animate

func (t *ColorTween) Animate(animator Animator) Animator

Animate sets the Animator that drives the Tween.

func (*ColorTween) Animator

func (t *ColorTween) Animator() Animator

Animator returns the Animator driving the Tween.

func (*ColorTween) Range

func (t *ColorTween) Range(from, to gfx.Color) *ColorTween

Range sets the beginning and ending value of the ColorTween.

func (*ColorTween) Value

func (t *ColorTween) Value() gfx.Color

Returns the interpolated value for the current value of the given Animator.

type EndCallback

type EndCallback func(reverse bool)

type F32Tween

type F32Tween struct {
	// contains filtered or unexported fields
}

A float32 linear interpolation between a beginning and ending value. It use the Animator as the input.

func (*F32Tween) Animate

func (t *F32Tween) Animate(am Animator) Animator

Animate sets the Animator that drives the Tween.

func (*F32Tween) Animator

func (t *F32Tween) Animator() Animator

Animator returns the Animator driving the Tween.

func (*F32Tween) Range

func (t *F32Tween) Range(from, to float32) *F32Tween

Range sets the beginning and ending value of the F32Tween.

func (*F32Tween) Value

func (t *F32Tween) Value() float32

Returns the interpolated value for the current value of the given Animator.

type LoopType

type LoopType uint8

Defines what this animation should do when it reaches the end.

const (
	Restart LoopType = iota
	PingPong
)

type TweenEngine

type TweenEngine struct {
	// contains filtered or unexported fields
}

func NewEngine

func NewEngine() *TweenEngine

func (*TweenEngine) Delete

func (eng *TweenEngine) Delete(index int)

func (*TweenEngine) Duration

func (eng *TweenEngine) Duration(index int) float32

func (*TweenEngine) Forward

func (eng *TweenEngine) Forward(index int)

Play an animation, produces values that range from 0.0 to 1.0, during a given duration.

func (*TweenEngine) New

func (eng *TweenEngine) New() (uid int)

func (*TweenEngine) NewAnimator

func (eng *TweenEngine) NewAnimator() Animator

func (*TweenEngine) Reverse

func (eng *TweenEngine) Reverse(index int)

Play an animation in reverse. If the animation is already running, stop itself and play backwards from the point. If the animation is not running, then it will start from the end and play backwards.

func (*TweenEngine) SetCompleteCallback

func (eng *TweenEngine) SetCompleteCallback(index int, cb EndCallback)

func (*TweenEngine) SetDuration

func (eng *TweenEngine) SetDuration(index int, d float32)

Duration is the length of time this animation should last.

func (*TweenEngine) SetFunction

func (eng *TweenEngine) SetFunction(index int, fn ease.Function)

func (*TweenEngine) SetRepeat

func (eng *TweenEngine) SetRepeat(index int, count int, loop LoopType)

Repeat the animation. If playback type is forward, restart the animation from start, if the playback type is backward or ping-pong,

func (*TweenEngine) SetTimeScale

func (eng *TweenEngine) SetTimeScale(sk float32)

func (*TweenEngine) SetUpdateCallback

func (eng *TweenEngine) SetUpdateCallback(index int, cb UpdateCallback)

func (*TweenEngine) Stop

func (eng *TweenEngine) Stop(index int)

Stops running this animation.

func (*TweenEngine) Update

func (eng *TweenEngine) Update(dt float32)

It's not easy to maintain the callback, one many add or delete animation while looping. Thanks to our delayed deleting strategy that delete operation only mark the animation 'Disposed' and will not change the size of the active animation. But add new animation will change the size, since new animation is always appended to the end. We can easily know the real size. Note: we need a BETTER callback policy.

func (*TweenEngine) Value

func (eng *TweenEngine) Value(index int) (f float32)

type UpdateCallback

type UpdateCallback func(reverse bool, f float32)

type Value

type Value struct {
	// contains filtered or unexported fields
}

type Vec2Tween

type Vec2Tween struct {
	// contains filtered or unexported fields
}

A f32.Vec2 linear interpolation between a beginning and ending value. It use the Animator as the input.

func (*Vec2Tween) Animate

func (t *Vec2Tween) Animate(am Animator) Animator

Animate sets the Animator that drives the Tween.

func (*Vec2Tween) Animator

func (t *Vec2Tween) Animator() Animator

Animator returns the Animator driving the Tween.

func (*Vec2Tween) Range

func (t *Vec2Tween) Range(from, to f32.Vec2) *Vec2Tween

Range sets the beginning and ending value of the Vec2Tween.

func (*Vec2Tween) Value

func (t *Vec2Tween) Value() f32.Vec2

Returns the interpolated value for the current value of the given Animator.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL