animate

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package animate implements animations, easings and interpolaters.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorInterpolate

ColorInterpolate wraps n and returns a notifier with the corresponding interpolated colors.

func FloatInterpolate

FloatInterpolate wraps n and returns a notifier with the corresponding interpolated floats.

Types

type Animation

type Animation interface {
	Duration() time.Duration
	Tick(time.Duration) float64
}

Animation is an interface that represents a float64 that changes over a fixed duration.

type Basic

type Basic struct {
	Start float64
	End   float64
	Ease  FloatInterpolater
	Dur   time.Duration // Duration
}

Basic is an animation that goes from Start to End with duration Dur.

func (*Basic) Duration

func (a *Basic) Duration() time.Duration

Duration implements the Animation interface.

func (*Basic) Tick

func (a *Basic) Tick(t time.Duration) float64

Tick implements the Animation interface.

type ColorInterpolater

type ColorInterpolater interface {
	Interpolate(float64) color.Color
}

ColorInterpolater represents an object that interpolates between colors given a float64 between 0-1.

type CubicBezierEase

type CubicBezierEase struct {
	X0, Y0, X1, Y1 float64
}

CubicBezierEase interpolates between 1-0 using a Cubic Bézier curve. The parameters are cubic control parameters. The curve starts at (0,0) going toward (x0,y0), and arrives at (1,1) coming from (x1,y1).

func (CubicBezierEase) Interpolate

func (e CubicBezierEase) Interpolate(a float64) float64

Interpolate implements the Interpolater interface.

func (CubicBezierEase) Notifier

Notifier is a convenience method around animate.FloatInterpolate(n, e).

type FloatInterpolater

type FloatInterpolater interface {
	Interpolate(float64) float64
}

ColorInterpolater represents an object that interpolates between floats given a float64 between 0-1.

var (
	DefaultEase      FloatInterpolater = CubicBezierEase{0.25, 0.1, 0.25, 1}
	DefaultInEase    FloatInterpolater = CubicBezierEase{0.42, 0, 1, 1}
	DefaultOutEase   FloatInterpolater = CubicBezierEase{0, 0, 0.58, 1}
	DefaultInOutEase FloatInterpolater = CubicBezierEase{0.42, 0, 0.58, 1}
)

type FloatLerp

type FloatLerp struct {
	Start, End float64
}

FloatLerp interpolates between Start and End linearly.

func (FloatLerp) Interpolate

func (f FloatLerp) Interpolate(a float64) float64

Interpolate implements the Interpolater interface.

func (FloatLerp) Notifier

Notifier is a convenience method around animate.FloatInterpolate(n, e)

type LinearEase

type LinearEase struct {
}

LinearEase interpolates between 1-0 in a linear fashion.

func (LinearEase) Interpolate

func (e LinearEase) Interpolate(a float64) float64

Interpolate implements the Interpolater interface.

func (LinearEase) Notifier

Notifier is a convenience method around animate.FloatInterpolate(n, e)

type PolyInEase

type PolyInEase struct {
	Exp float64
}

PolyInEase interpolates between Start and End with a polynomial easing.

func (PolyInEase) Interpolate

func (e PolyInEase) Interpolate(a float64) float64

Interpolate implements the Interpolater interface.

func (PolyInEase) Notifier

Notifier is a convenience method around animate.FloatInterpolate(n, e)

type PolyInOutEase

type PolyInOutEase struct {
	ExpIn  float64
	ExpOut float64
}

PolyInOutEase interpolates between Start and End with a symmetric polynomial easing.

func (PolyInOutEase) Interpolate

func (e PolyInOutEase) Interpolate(a float64) float64

Interpolate implements the Interpolater interface.

func (PolyInOutEase) Notifier

Notifier is a convenience method around animate.FloatInterpolate(n, e)

type PolyOutEase

type PolyOutEase struct {
	Exp float64
}

PolyOutEase interpolates between Start and End with a reverse polynomial easing.

func (PolyOutEase) Interpolate

func (e PolyOutEase) Interpolate(a float64) float64

Interpolate implements the Interpolater interface.

func (PolyOutEase) Notifier

Notifier is a convenience method around animate.FloatInterpolate(n, e)

type RGBALerp

type RGBALerp struct {
	Start, End color.Color
}

RGBALerp interpolates between colors Start and End.

func (RGBALerp) Interpolate

func (e RGBALerp) Interpolate(a float64) color.Color

Interpolate implements the ColorInterpolater interface

func (RGBALerp) Notifier

Notifier is a convenience method around animate.ColorInterpolate(n, e)

type Value

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

Value is an struct that runs Animations and emits float64s.

func (*Value) Notify

func (v *Value) Notify(f func()) comm.Id

Notify implements the comm.Notifier interface.

func (*Value) Run

func (v *Value) Run(a Animation) (cancelFunc func())

Run runs animation a on v. Cancels any previously running animations on v.

func (*Value) SetValue

func (v *Value) SetValue(val float64)

SetValue updates Value, calls any subscribed functions and cancels any running animations.

func (*Value) Unnotify

func (v *Value) Unnotify(id comm.Id)

Unnotify implements the comm.Notifier interface.

func (*Value) Value

func (v *Value) Value() float64

Value returns the current value of v.

Jump to

Keyboard shortcuts

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