Package net.dermetfan.gdx
Class CharSequenceInterpolator
java.lang.Object
net.dermetfan.gdx.CharSequenceInterpolator
public class CharSequenceInterpolator
extends java.lang.Object
Interpolates the
endIndex of a subSequence of a CharSequence by time and charsPerSecond.-
Constructor Summary
Constructors Constructor Description CharSequenceInterpolator(float charsPerSecond) -
Method Summary
Modifier and Type Method Description static floatcharsPerSecondFor(float duration, int length)static floatduration(int length, float charsPerSecond)floatgetCharsPerSecond()com.badlogic.gdx.math.InterpolationgetInterpolation()floatgetTime()java.lang.CharSequenceinterpolate(java.lang.CharSequence seq)static java.lang.CharSequenceinterpolate(java.lang.CharSequence seq, float time, float charsPerSecond, int beginIndex, int endIndex, com.badlogic.gdx.math.Interpolation interpolation)static java.lang.CharSequenceinterpolate(java.lang.CharSequence seq, float time, float charsPerSecond, com.badlogic.gdx.math.Interpolation interpolation)static floatlinear(float time, float charsPerSecond, int length)voidsetCharsPerSecond(float charsPerSecond)voidsetInterpolation(com.badlogic.gdx.math.Interpolation interpolation)voidsetTime(float time)voidupdate(float delta)increasestimeby the given deltajava.lang.CharSequenceupdateAndInterpolate(java.lang.CharSequence seq, float delta)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
CharSequenceInterpolator
public CharSequenceInterpolator(float charsPerSecond)- Parameters:
charsPerSecond- thecharsPerSecond
-
-
Method Details
-
duration
public static float duration(int length, float charsPerSecond)- Returns:
- the duration it takes to fully interpolate a
CharSequenceof the givenlengthwith the givencharsPerSecond
-
charsPerSecondFor
public static float charsPerSecondFor(float duration, int length)- Parameters:
duration- the desired duration of the interpolation using the returned chars per secondlength- the length of theCharSequence- Returns:
- the chars per second needed to get the desired duration when interpolating
-
linear
public static float linear(float time, float charsPerSecond, int length)- Parameters:
time- thetimecharsPerSecond- thecharsPerSecondlength- the length of theCharSequence- Returns:
- the result of linear interpolation / percent of the
durationat the giventime
-
interpolate
public static java.lang.CharSequence interpolate(java.lang.CharSequence seq, float time, float charsPerSecond, com.badlogic.gdx.math.Interpolation interpolation) -
interpolate
public static java.lang.CharSequence interpolate(java.lang.CharSequence seq, float time, float charsPerSecond, int beginIndex, int endIndex, com.badlogic.gdx.math.Interpolation interpolation)- Parameters:
seq- theCharSequenceto interpolatetime- thetimecharsPerSecond- thecharsPerSecondbeginIndex- the index at which the returnedCharSequenceshould startendIndex- the index at which the returnedCharSequenceshould end if the givenInterpolationapplied1interpolation- theInterpolationto use- Returns:
- a
subsequencerepresenting the givenseqfrombeginIndextoendIndexwith itslengthinterpolated using the giveninterpolation
-
update
public void update(float delta)increasestimeby the given delta -
interpolate
public java.lang.CharSequence interpolate(java.lang.CharSequence seq) -
updateAndInterpolate
public java.lang.CharSequence updateAndInterpolate(java.lang.CharSequence seq, float delta) -
getInterpolation
public com.badlogic.gdx.math.Interpolation getInterpolation()- Returns:
- the
interpolation
-
setInterpolation
public void setInterpolation(com.badlogic.gdx.math.Interpolation interpolation)- Parameters:
interpolation- theinterpolationto set
-
getCharsPerSecond
public float getCharsPerSecond()- Returns:
- the
charsPerSecond
-
setCharsPerSecond
public void setCharsPerSecond(float charsPerSecond)- Parameters:
charsPerSecond- thecharsPerSecondto set
-
getTime
public float getTime()- Returns:
- the
time
-
setTime
public void setTime(float time)- Parameters:
time- thetimeto set
-