Package dev.oxydien.mathimations.utils
Class TimingUtils
java.lang.Object
dev.oxydien.mathimations.utils.TimingUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic floatanimationWindow(float cur, float animDuration, float minInterval, float maxInterval) Creates pseudo-random animation windows based on time.
-
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 valueanimDuration- Duration of the animation in secondsminInterval- Minimum time between animation triggersmaxInterval- Maximum time between animation triggers- Returns:
- Progress through animation (0-1) or 0 if not animating
-