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 float
charsPerSecondFor(float duration, int length)
static float
duration(int length, float charsPerSecond)
float
getCharsPerSecond()
com.badlogic.gdx.math.Interpolation
getInterpolation()
float
getTime()
java.lang.CharSequence
interpolate(java.lang.CharSequence seq)
static java.lang.CharSequence
interpolate(java.lang.CharSequence seq, float time, float charsPerSecond, int beginIndex, int endIndex, com.badlogic.gdx.math.Interpolation interpolation)
static java.lang.CharSequence
interpolate(java.lang.CharSequence seq, float time, float charsPerSecond, com.badlogic.gdx.math.Interpolation interpolation)
static float
linear(float time, float charsPerSecond, int length)
void
setCharsPerSecond(float charsPerSecond)
void
setInterpolation(com.badlogic.gdx.math.Interpolation interpolation)
void
setTime(float time)
void
update(float delta)
increasestime
by the given deltajava.lang.CharSequence
updateAndInterpolate(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
CharSequence
of the givenlength
with 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
- thetime
charsPerSecond
- thecharsPerSecond
length
- the length of theCharSequence
- Returns:
- the result of linear interpolation / percent of the
duration
at 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
- theCharSequence
to interpolatetime
- thetime
charsPerSecond
- thecharsPerSecond
beginIndex
- the index at which the returnedCharSequence
should startendIndex
- the index at which the returnedCharSequence
should end if the givenInterpolation
applied
1interpolation
- theInterpolation
to use- Returns:
- a
subsequence
representing the givenseq
frombeginIndex
toendIndex
with itslength
interpolated using the giveninterpolation
-
update
public void update(float delta)increasestime
by 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
- theinterpolation
to set
-
getCharsPerSecond
public float getCharsPerSecond()- Returns:
- the
charsPerSecond
-
setCharsPerSecond
public void setCharsPerSecond(float charsPerSecond)- Parameters:
charsPerSecond
- thecharsPerSecond
to set
-
getTime
public float getTime()- Returns:
- the
time
-
setTime
public void setTime(float time)- Parameters:
time
- thetime
to set
-