Interface Spring
public interface Spring
Values keyed by any object that ease toward their targets without overshooting, at the same
speed at any frame rate. Time passes on its own: each update moves a value by the time since
its last one.
A key seen for the first time starts at its target, and so does one that has not been updated for a while, so something that was out of sight does not animate a change it missed.
A key seen for the first time starts at its target, and so does one that has not been updated for a while, so something that was out of sight does not animate a change it missed.
-
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Forgets every value, so each key starts at its target again.voidPuts the value forkeyatvalue, standing still, for example to have a new piece grow from 0.static Springsettling(double seconds) static Springsettling(DoubleSupplier seconds) default floatMoves the value forkeytoward 1 whileon, toward 0 otherwise.floatMoves the value forkeytowardtarget.
-
Method Details
-
settling
- Parameters:
seconds- About how long a value takes to settle on a new target; 0 jumps- Returns:
- New springs
-
settling
- Parameters:
seconds- Read on every update, so the time can follow a setting; 0 jumps- Returns:
- New springs
-
update
Moves the value forkeytowardtarget.- Returns:
- The current value
-
update
Moves the value forkeytoward 1 whileon, toward 0 otherwise.- Returns:
- The current value, 0 to 1
-
set
Puts the value forkeyatvalue, standing still, for example to have a new piece grow from 0. -
clear
void clear()Forgets every value, so each key starts at its target again.
-