Class TimingUtils

java.lang.Object
dev.oxydien.mathimations.utils.TimingUtils

public class TimingUtils extends Object
  • Constructor Details

    • TimingUtils

      public TimingUtils()
  • Method Details

    • animationWindow

      public static float animationWindow(float cur, float animDuration, float minInterval, float maxInterval)
      Creates pseudo-random animation windows based on time. Returns a value between 0 and 1 indicating progress through the animation window, or 0 if outside any window. Example:
       float curTime = AnimationContext.getTimeSinceEntityStart();
       float animDuration = 0.3f; // 300 millisecond
       float minInterval = 2.0f; // 2 seconds
       float maxInterval = 3.0f; // 3 seconds
       float progress = animationWindow(curTime, animDuration, minInterval, maxInterval);
       if (progress > 0) {
           // Animation is active
           // You can use progress to interpolate between states
           // Tip: the progress can be used as X offset of an sin wave
       }
       
      Parameters:
      cur - Current time value
      animDuration - Duration of the animation in seconds
      minInterval - Minimum time between animation triggers
      maxInterval - Maximum time between animation triggers
      Returns:
      Progress through animation (0-1) or 0 if not animating