interp

package
v0.0.0-...-2891c51 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DynamicValue

func DynamicValue(val float64, fixedTime, dt time.Duration) float64

This will calculate

Types

type AddFunc

type AddFunc struct {
	A, B Function
}

func (AddFunc) Interp

func (f AddFunc) Interp(t float64) float64

type BezFunc

type BezFunc struct {
	Radius float64
	Dur    float64
	Bezier *Bezier
}

func (BezFunc) Interp

func (f BezFunc) Interp(t float64) float64

type Bezier

type Bezier struct {
	bezier2.T
}
var BezLerp *Bezier = &Bezier{
	bezier2.T{
		vec2.T{0.0, 0.0},
		vec2.T{0.0, 0.0},
		vec2.T{1.0, 1.0},
		vec2.T{1.0, 1.0},
	},
}
var EaseIn *Bezier = &Bezier{
	bezier2.T{
		vec2.T{0.0, 0.0},
		vec2.T{0.0, 1.0},
		vec2.T{0.0, 1.0},
		vec2.T{1.0, 1.0},
	},
}
var EaseInOut *Bezier = &Bezier{
	bezier2.T{
		vec2.T{0.0, 0.0},
		vec2.T{1.0, 0.0},
		vec2.T{0.0, 1.0},
		vec2.T{1.0, 1.0},
	},
}
var EaseOut *Bezier = &Bezier{
	bezier2.T{
		vec2.T{0.0, 0.0},
		vec2.T{1.0, 0.0},
		vec2.T{1.0, 0.0},
		vec2.T{1.0, 1.0},
	},
}
var EaseOutQuint *Bezier = &Bezier{
	bezier2.T{
		vec2.T{0.0, 0.0},
		vec2.T{0.22, 1.0},
		vec2.T{0.36, 1.0},
		vec2.T{1.0, 1.0},
	},
}

https://cubic-bezier.com/#.22,1,.36,1

var EaseTest *Bezier = &Bezier{
	bezier2.T{
		vec2.T{0.0, 0.0},
		vec2.T{0.0, 1.0},
		vec2.T{0.0, 2.0},
		vec2.T{1.0, 1.0},
	},
}

func Const

func Const(val float64) *Bezier

func NewCubicBezier

func NewCubicBezier(b, c phy2.Vec) *Bezier

Note: https://www.w3schools.com/cssref/func_cubic-bezier.php#:~:text=P0%20is%20(0%2C%200),transition%2Dtiming%2Dfunction%20property. Essentially: First point is (0, 0), last point is (1, 1) and you can define the two points in the middle

func (*Bezier) Float32

func (i *Bezier) Float32(a, b float32, t float64) float32

func (*Bezier) Float64

func (i *Bezier) Float64(a, b float64, t float64) float64

func (*Bezier) Uint8

func (i *Bezier) Uint8(a, b uint8, t float64) uint8

func (*Bezier) Vec2

func (i *Bezier) Vec2(a, b vec2.T, t float64) vec2.T

type CosFunc

type CosFunc struct {
	Radius float64
	Freq   float64
	ShiftY float64
}

func (CosFunc) Interp

func (s CosFunc) Interp(t float64) float64

type Equation

type Equation struct {
	Func Function
}

func (*Equation) Float32

func (i *Equation) Float32(a, b float32, t float64) float32

func (*Equation) Float64

func (i *Equation) Float64(a, b float64, t float64) float64

func (*Equation) Uint8

func (i *Equation) Uint8(a, b uint8, t float64) uint8

func (*Equation) Vec2

func (i *Equation) Vec2(a, b vec2.T, t float64) vec2.T

type Function

type Function interface {
	Interp(t float64) float64
}

type Interp

type Interp interface {
	Uint8(uint8, uint8, float64) uint8
	Float32(float32, float32, float64) float32
	Float64(float64, float64, float64) float64
	Vec2(vec2.T, vec2.T, float64) vec2.T
}

type Lerp

type Lerp struct {
}
var Linear *Lerp = &Lerp{}

func (Lerp) Float32

func (i Lerp) Float32(a, b float32, t float64) float32

func (Lerp) Float64

func (i Lerp) Float64(a, b float64, t float64) float64

func (Lerp) Uint8

func (i Lerp) Uint8(a, b uint8, t float64) uint8

func (Lerp) Vec2

func (i Lerp) Vec2(a, b vec2.T, t float64) vec2.T

type LineFunc

type LineFunc struct {
	Slope     float64
	Intercept float64 // The Y intercept
}

func (LineFunc) Interp

func (f LineFunc) Interp(t float64) float64

type MultFunc

type MultFunc struct {
	A, B Function
}

func (MultFunc) Interp

func (f MultFunc) Interp(t float64) float64

type SinFunc

type SinFunc struct {
	Radius float64
	Freq   float64
	ShiftY float64
}

func (SinFunc) Interp

func (s SinFunc) Interp(t float64) float64

type StepF

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

func Step

func Step(divRatio float64, a, b Interp) StepF

func (StepF) Float32

func (i StepF) Float32(a, b float32, t float64) float32

func (StepF) Float64

func (i StepF) Float64(a, b float64, t float64) float64

func (StepF) Uint8

func (i StepF) Uint8(a, b uint8, t float64) uint8

func (StepF) Vec2

func (i StepF) Vec2(a, b vec2.T, t float64) vec2.T

Jump to

Keyboard shortcuts

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