Class Smooth
java.lang.Object
lol.trq.helios.anim.Smooth
A value that glides towards a target with exponential damping, the same at any frame rate. Good for things whose
target moves every frame: a slider knob, a health bar, a scroll offset.
Smooth health = new Smooth(12); // 12 per second: closes about 63% of the gap in 1/12 s
health.target(player.health());
float shown = health.update();
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
Smooth
public Smooth(double ratePerSecond) Creates a smoothed value at 0, using the system clock.- Parameters:
ratePerSecond- how quickly it closes the gap; higher is snappier
-
Smooth
Creates a smoothed value at 0.- Parameters:
ratePerSecond- how quickly it closes the gapclock- the time source
-
-
Method Details
-
target
Sets where the value is heading.- Parameters:
target- the target- Returns:
- this
-
snap
Jumps to a value and rests there.- Parameters:
v- the value- Returns:
- this
-
update
public float update()Advances to now and returns the value. Call once per frame.- Returns:
- the current value
-
value
public double value()Returns the value without advancing.- Returns:
- the value at the last update
-
target
public double target()Returns the target.- Returns:
- the target
-