Class CharSequenceInterpolator

java.lang.Object
net.dermetfan.gdx.CharSequenceInterpolator

public class CharSequenceInterpolator extends Object
Interpolates the endIndex of a subSequence of a CharSequence by time and charsPerSecond.
  • Constructor Details

    • CharSequenceInterpolator

      public CharSequenceInterpolator(float charsPerSecond)
      Parameters:
      charsPerSecond - the charsPerSecond
  • Method Details

    • duration

      public static float duration(int length, float charsPerSecond)
      Returns:
      the duration it takes to fully interpolate a CharSequence of the given length with the given charsPerSecond
    • charsPerSecondFor

      public static float charsPerSecondFor(float duration, int length)
      Parameters:
      duration - the desired duration of the interpolation using the returned chars per second
      length - the length of the CharSequence
      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 - the time
      charsPerSecond - the charsPerSecond
      length - the length of the CharSequence
      Returns:
      the result of linear interpolation / percent of the duration at the given time
    • interpolate

      public static CharSequence interpolate(CharSequence seq, float time, float charsPerSecond, com.badlogic.gdx.math.Interpolation interpolation)
      See Also:
    • interpolate

      public static CharSequence interpolate(CharSequence seq, float time, float charsPerSecond, int beginIndex, int endIndex, com.badlogic.gdx.math.Interpolation interpolation)
      Parameters:
      seq - the CharSequence to interpolate
      time - the time
      charsPerSecond - the charsPerSecond
      beginIndex - the index at which the returned CharSequence should start
      endIndex - the index at which the returned CharSequence should end if the given Interpolation applied 1
      interpolation - the Interpolation to use
      Returns:
      a subsequence representing the given seq from beginIndex to endIndex with its length interpolated using the given interpolation
    • update

      public void update(float delta)
      increases time by the given delta
    • interpolate

      public CharSequence interpolate(CharSequence seq)
      See Also:
    • updateAndInterpolate

      public CharSequence updateAndInterpolate(CharSequence seq, float delta)
      updates the time and returns the interpolated given CharSequence
    • getInterpolation

      public com.badlogic.gdx.math.Interpolation getInterpolation()
      Returns:
      the interpolation
    • setInterpolation

      public void setInterpolation(com.badlogic.gdx.math.Interpolation interpolation)
      Parameters:
      interpolation - the interpolation to set
    • getCharsPerSecond

      public float getCharsPerSecond()
      Returns:
      the charsPerSecond
    • setCharsPerSecond

      public void setCharsPerSecond(float charsPerSecond)
      Parameters:
      charsPerSecond - the charsPerSecond to set
    • getTime

      public float getTime()
      Returns:
      the time
    • setTime

      public void setTime(float time)
      Parameters:
      time - the time to set