You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
982 B
54 lines
982 B
10 years ago
|
package mightypork.gamecore.util.math.timing.animation;
|
||
10 years ago
|
|
||
10 years ago
|
|
||
10 years ago
|
import mightypork.gamecore.util.math.Calc;
|
||
|
import mightypork.gamecore.util.math.Calc.Deg;
|
||
|
import mightypork.gamecore.util.math.Easing;
|
||
10 years ago
|
|
||
|
|
||
|
/**
|
||
10 years ago
|
* Degree animator
|
||
10 years ago
|
*
|
||
10 years ago
|
* @author Ondřej Hruška (MightyPork)
|
||
10 years ago
|
*/
|
||
10 years ago
|
public class NumAnimatedDeg extends NumAnimated {
|
||
10 years ago
|
|
||
10 years ago
|
public NumAnimatedDeg(NumAnimated other)
|
||
|
{
|
||
10 years ago
|
super(other);
|
||
|
}
|
||
10 years ago
|
|
||
|
|
||
10 years ago
|
public NumAnimatedDeg(double value)
|
||
|
{
|
||
10 years ago
|
super(value);
|
||
|
}
|
||
10 years ago
|
|
||
|
|
||
10 years ago
|
public NumAnimatedDeg(double value, Easing easing)
|
||
|
{
|
||
10 years ago
|
super(value, easing);
|
||
10 years ago
|
}
|
||
10 years ago
|
|
||
|
|
||
10 years ago
|
@Override
|
||
10 years ago
|
public double value()
|
||
10 years ago
|
{
|
||
10 years ago
|
if (duration == 0) return Deg.norm(to);
|
||
10 years ago
|
return Calc.interpolateDeg(from, to, (elapsedTime / duration), easingCurrent);
|
||
10 years ago
|
}
|
||
10 years ago
|
|
||
|
|
||
10 years ago
|
@Override
|
||
10 years ago
|
protected double getProgressFromValue(double value)
|
||
10 years ago
|
{
|
||
10 years ago
|
final double whole = Deg.diff(from, to);
|
||
10 years ago
|
if (Deg.diff(value, from) < whole && Deg.diff(value, to) < whole) {
|
||
10 years ago
|
final double partial = Deg.diff(from, value);
|
||
10 years ago
|
return partial / whole;
|
||
|
}
|
||
10 years ago
|
|
||
10 years ago
|
return 0;
|
||
10 years ago
|
}
|
||
|
}
|