easing

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DenormalizePosition

func DenormalizePosition(currVal float64, startVal, endVal uint) uint

DenormalizePosition returns the value of currVal in the startVal and endVal range

func NormalisePosition

func NormalisePosition(startPos, endPos, currPos uint) float64

NormalisePosition returns the normalized [0-1] position for currPos, between startPos and endPos

Types

type EaseIn

type EaseIn struct {
	Power float64
}

func NewEaseIn

func NewEaseIn(power float64) *EaseIn

NewEaseIn creates a new ease-in object for envelope processing. The curve has a slow start with a fast end. The power determines the steepness of the curve and needs to be [>=1]. Values like 2-3 gives a smooth transition, while >5 gives a steep curve.

func (EaseIn) GetValue

func (ei EaseIn) GetValue(startPos, endPos, currPos uint) float64

GetValue does an ease-in interpolation between startPos and endPos. Returns the normalized value [0-1] at currPos.

type EaseInOut

type EaseInOut struct {
	Power float64
}

func NewEaseInOut

func NewEaseInOut() *EaseInOut

NewEaseInOut creates a new ease-in-out object for envelope processing. The has a slow start and end, and a fast middle section. The power determines the steepness of the curve and needs to be [>=1]. Values like 2-3 gives a smooth transition, while >5 gives a steep curve.

func (EaseInOut) GetValue

func (eio EaseInOut) GetValue(startPos, endPos, currPos uint) float64

GetValue does a cubic ease-in-out interpolation between startPos and endPos. Returns the normalized value [0-1] at currPos.

type EaseOut

type EaseOut struct {
	Power float64
}

func NewEaseOut

func NewEaseOut(power float64) *EaseOut

NewEaseOut creates a new ease-out object for envelope processing. The curve has a fast start with a slow end. The power determines the steepness of the curve and needs to be [>=1]. Values like 2-3 gives a smooth transition, while >5 gives a steep curve.

func (EaseOut) GetValue

func (eo EaseOut) GetValue(startPos, endPos, currPos uint) float64

GetValue does an ease-out interpolation between startPos and endPos. Returns the normalized value [0-1] at currPos.

type Easing

type Easing interface {
	GetValue(startPos, endPos, currPos uint) float64
}

Easing is an interface for easing functions for envelope processing.

type Exponential

type Exponential struct {
	Factor float64 // >5
}

func NewExponential

func NewExponential(factor float64) *Exponential

NewExponential creates a new exponential interpolation object for envelope processing. Factor must be [>5].

func (Exponential) GetValue

func (exp Exponential) GetValue(startPos, endPos, currPos uint) float64

GetValue does a exponential interpolation between startPos and endPos. Returns the normalized value [0-1] at currPos.

type InverseExponential

type InverseExponential struct {
	Factor float64 // >5
}

func NewInverseExponential

func NewInverseExponential() *InverseExponential

NewInverseExponential creates a new inverse exponential interpolation object for envelope processing. Factor must be [>5].

func (InverseExponential) GetValue

func (invexp InverseExponential) GetValue(startPos, endPos, currPos uint) float64

GetValue does an inverse exponential interpolation between startPos and endPos. Returns the normalized value [0-1] at currPos.

type InverseLogarithmic

type InverseLogarithmic struct {
	Base float64
}

func NewInverseLogarithmic

func NewInverseLogarithmic(base float64) *InverseLogarithmic

NewInverseLogarithmic creates a new inverse logarithmic interpolation object for envelope processing. The base should be [>1]. Recommended default: 10

func (InverseLogarithmic) GetValue

func (invlog InverseLogarithmic) GetValue(startPos, endPos, currPos uint) float64

GetValue does a logarithmic interpolation between startPos and endPos. Returns the normalized value [0-1] at currPos.

type LERP

type LERP struct {
}

func NewLERP

func NewLERP() *LERP

NewLERP creates a new linear interpolation object for envelope processing.

func (LERP) GetValue

func (lerp LERP) GetValue(startPos, endPos, currPos uint) float64

GetValue does a linear interpolation between startPos and endPos. Returns the normalized value [0-1] at currPos.

type Logarithmic

type Logarithmic struct {
	Base float64
}

func NewLogarithmic

func NewLogarithmic(base float64) *Logarithmic

NewLogarithmic creates a new logarithmic interpolation object for envelope processing. The base should be [>1]. Recommended default: 10

func (Logarithmic) GetValue

func (log Logarithmic) GetValue(startPos, endPos, currPos uint) float64

GetValue does a logarithmic interpolation between startPos and endPos. Returns the normalized value [0-1] at currPos.

type SCurve

type SCurve struct {
	Sharpness float64
	Midpoint  float64
}

func NewSCurve

func NewSCurve(sharpness float64, midpoint float64) *SCurve

NewSCurve creates a new SCurve object for envelope processing.

The sharpness determines the steepness of the S-curve. Low sharpness means a more gradual transition, high sharpness means a steeper curve. Use positive values here, like 1.0, 5.0, 10.0, ...

The midpoint specifies the X-axis value where the curve inflection occurs. This value should be in the range [0-1]

func (SCurve) GetValue

func (sc SCurve) GetValue(startPos, endPos, currPos uint) float64

GetValue does a scurve (sigmoid) interpolation between startPos and endPos. Returns the normalized value [0-1] at currPos.

Jump to

Keyboard shortcuts

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