Package tripleplay.util
Class Interpolator
java.lang.Object
tripleplay.util.Interpolator
Abstracts the process of interpolation between two values.
-
Field Summary
Modifier and TypeFieldDescriptionstatic Interpolator
static Interpolator
An interpolator that starts to change slowly and ramps up to full speed.static Interpolator
An interpolator that undershoots the starting value, then speeds up into the final valuestatic Interpolator
An interpolator that eases away from the starting value, speeds up, then eases into the final value.static Interpolator
An interpolator that starts to change quickly and eases into the final value.static Interpolator
An interpolator that eases into the final value and overshoots it before settling on it.static Interpolator
An interpolator that eases past the final value then back towards it elastically.static Interpolator
A linear interpolator.static Interpolator
An interpolator that always returns the starting position. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract float
apply
(float v) Interpolates between zero and one according to this interpolator's function.float
apply
(float dt, float t) Interpolates between zero and one according to this interpolator's function.float
apply
(float start, float range, float dt, float t) Interpolates between two values.float
applyClamp
(float dt, float t) Interpolates between two values, as inapply(float,float)
except thatdt
is clamped to [0..t] to avoid interpolation weirdness ifdt
is ever negative or exceedst
.float
applyClamp
(float start, float range, float dt, float t) Interpolates between two values, as inapply(float)
except thatdt
is clamped to [0..t] to avoid interpolation weirdness ifdt
is ever negative or exceedst
.
-
Field Details
-
NOOP
An interpolator that always returns the starting position. -
LINEAR
A linear interpolator. -
EASE_IN
An interpolator that starts to change slowly and ramps up to full speed. -
EASE_OUT
An interpolator that starts to change quickly and eases into the final value. -
EASE_INOUT
An interpolator that eases away from the starting value, speeds up, then eases into the final value. -
EASE_IN_BACK
An interpolator that undershoots the starting value, then speeds up into the final value -
EASE_OUT_BACK
An interpolator that eases into the final value and overshoots it before settling on it. -
BOUNCE_OUT
-
EASE_OUT_ELASTIC
An interpolator that eases past the final value then back towards it elastically.
-
-
Constructor Details
-
Interpolator
public Interpolator()
-
-
Method Details
-
apply
public abstract float apply(float v) Interpolates between zero and one according to this interpolator's function.- Parameters:
v
- a value between zero and one (usuallyelapsed/total
time).
-
apply
public float apply(float dt, float t) Interpolates between zero and one according to this interpolator's function.- Parameters:
dt
- the amount of time that has elapsed.t
- the total amount of time for the interpolation. If t == 0, the result is undefined.
-
applyClamp
public float applyClamp(float dt, float t) Interpolates between two values, as inapply(float,float)
except thatdt
is clamped to [0..t] to avoid interpolation weirdness ifdt
is ever negative or exceedst
. -
apply
public float apply(float start, float range, float dt, float t) Interpolates between two values.- Parameters:
start
- the starting value.range
- the difference between the ending value and the starting value.dt
- the amount of time that has elapsed.t
- the total amount of time for the interpolation. If t == 0, start+range will be returned.
-
applyClamp
public float applyClamp(float start, float range, float dt, float t) Interpolates between two values, as inapply(float)
except thatdt
is clamped to [0..t] to avoid interpolation weirdness ifdt
is ever negative or exceedst
.
-