SimpleJavaEngine/src/main/java/speiger/src/coreengine/math/value/QuadraticValue.java

49 lines
1.1 KiB
Java

package speiger.src.coreengine.math.value;
import speiger.src.coreengine.math.MathUtils;
public class QuadraticValue extends Value
{
final float startValue;
final float medianValue;
final float endValue;
boolean smooth;
public QuadraticValue(float duration, float startValue, float medianValue, float endValue)
{
this(0F, duration, startValue, medianValue, endValue);
}
public QuadraticValue(float start, float duration, float startValue, float medianValue, float endValue)
{
super(start, duration);
this.startValue = startValue;
this.medianValue = medianValue;
this.endValue = endValue;
}
public QuadraticValue setSmooth()
{
smooth = true;
return this;
}
public QuadraticValue setSmooth(boolean smooth)
{
this.smooth = smooth;
return this;
}
@Override
protected float calculateProgress(float time)
{
return smooth ? MathUtils.smoothQuadraticCurve(startValue, medianValue, endValue, time) : MathUtils.quadraticCurve(startValue, medianValue, endValue, time);
}
@Override
protected void onFinished()
{
finishProgress();
}
}