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)
    increases time by the given delta
    java.lang.CharSequence updateAndInterpolate​(java.lang.CharSequence seq, float delta)
    updates the time and returns the interpolated given CharSequence

    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 - 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 java.lang.CharSequence interpolate​(java.lang.CharSequence seq, float time, float charsPerSecond, com.badlogic.gdx.math.Interpolation interpolation)
      See Also:
      interpolate(CharSequence, float, float, int, int, 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 - 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 java.lang.CharSequence interpolate​(java.lang.CharSequence seq)
      See Also:
      interpolate(CharSequence, float, float, Interpolation)
    • updateAndInterpolate

      public java.lang.CharSequence updateAndInterpolate​(java.lang.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