lerp

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BezierTween

type BezierTween struct {
	Start, StartHandle, EndHandle, End float64
}

BezierTween uses cubic Bézier curve equation for interpolation. For more info see https://en.wikipedia.org/wiki/B%C3%A9zier_curve, In case you are looking for visualization see https://www.desmos.com/calculator/d1ofwre0fr We are using only one dimensional curve as i do not consider to dimensions usefull for lib if you need to dimensions just use two Bezier-s

var ZB BezierTween

ZB is Zero Bezier Curve

func Bezier

func Bezier(start, startHandle, endHandle, end float64) BezierTween

Bezier is Bezier constructor

func (BezierTween) Value

func (b BezierTween) Value(t float64) float64

Value returns Value along the curve interpolated by t

type ConstantTween

type ConstantTween float64

ConstantTween does nothing, its a placeholder with no overhead

var ZC ConstantTween

ZC is ConstantTween zero value

func Const

func Const(value float64) ConstantTween

Const is COnstantTween constructor

func (ConstantTween) Gen

func (p ConstantTween) Gen() float64

Gen implements Generator interface

func (ConstantTween) Value

func (p ConstantTween) Value(t float64) float64

Value implements Tween interface

type Generator

type Generator interface {
	Gen() float64
}

Generator should generate a value

type LinearTween

type LinearTween struct {
	Start, End float64
}

LinearTween supports linear interpolation

var ZL LinearTween

ZL is LinearTween zero value

func (LinearTween) Value

func (l LinearTween) Value(t float64) float64

Value implements Tween interface

type RandomGenerator

type RandomGenerator struct {
	Min, Max float64
}

RandomGenerator generates random value between Min and Max

ZR is RandomGenerator zerovalue

func Random

func Random(value, offset float64) RandomGenerator

Random is RandomGenerator constructor

func (RandomGenerator) Gen

func (r RandomGenerator) Gen() float64

Gen implements Generator interface

type Tween

type Tween interface {
	Value(t float64) float64
}

Tween is something that projects t into some other value that can make smooth movement

func Linear

func Linear(start, end float64) Tween

Linear is lerp

Jump to

Keyboard shortcuts

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