Package me.deecaad.core.transition
Class Transition<T>
java.lang.Object
me.deecaad.core.transition.Transition<T>
- Type Parameters:
T- The value type.
A value-over-time curve. Stores an ordered list of
Keyframes in normalized time and an
Interpolator used to blend between consecutive keyframes. Immutable.
The first keyframe must have time == 0 and the last must have time == 1, with
monotonically increasing times in between.
-
Constructor Summary
ConstructorsConstructorDescriptionTransition(@NotNull List<Keyframe<T>> keyframes, @NotNull Interpolator<T> interpolator, int durationTicks) -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @NotNull Transition<T> constant(T value, @NotNull Interpolator<T> interpolator, int durationTicks) Single-keyframe transition that returnsvalueat every time.evaluate(double t) Evaluates the curve at normalized timet, clamped to[0, 1].evaluateAtTick(int tick) Convenience: evaluates attick / durationTicks.int@NotNull Interpolator<T> booleanstatic <T> @NotNull Transition<T> lerp(T from, T to, @NotNull Interpolator<T> interpolator, int durationTicks) static <T> @NotNull Transition<T> lerp(T from, T to, @NotNull Interpolator<T> interpolator, int durationTicks, @NotNull Easing easing) Two-keyframe transition fromfromtotowith the given easing applied across the segment.static <T> @NotNull Transition<T> pulse(T start, T peak, T end, @NotNull Interpolator<T> interpolator, int durationTicks, @NotNull Easing in, @NotNull Easing out) Three-keyframe pulse:start→peak(at t=0.5) →end, withineasing on the rise andouteasing on the fall.
-
Constructor Details
-
Transition
public Transition(@NotNull @NotNull List<Keyframe<T>> keyframes, @NotNull @NotNull Interpolator<T> interpolator, int durationTicks) - Parameters:
keyframes- The non-null keyframe list (copied, then sorted and validated).interpolator- The non-null interpolator for blending between consecutive keyframes.durationTicks- The duration in ticks; must be> 0. Used byevaluateAtTick(int)and playback helpers.
-
-
Method Details
-
getKeyframes
- Returns:
- The non-null immutable sorted keyframe list.
-
getInterpolator
-
getDurationTicks
public int getDurationTicks() -
isStepped
public boolean isStepped()- Returns:
trueif the interpolator is stepped (no meaningful intermediate values).
-
evaluate
Evaluates the curve at normalized timet, clamped to[0, 1].- Parameters:
t- The normalized time.- Returns:
- The non-null value.
-
evaluateAtTick
Convenience: evaluates attick / durationTicks.- Parameters:
tick- The current tick.- Returns:
- The non-null value.
-
constant
@NotNull public static <T> @NotNull Transition<T> constant(@NotNull T value, @NotNull @NotNull Interpolator<T> interpolator, int durationTicks) Single-keyframe transition that returnsvalueat every time. -
lerp
@NotNull public static <T> @NotNull Transition<T> lerp(@NotNull T from, @NotNull T to, @NotNull @NotNull Interpolator<T> interpolator, int durationTicks) -
lerp
@NotNull public static <T> @NotNull Transition<T> lerp(@NotNull T from, @NotNull T to, @NotNull @NotNull Interpolator<T> interpolator, int durationTicks, @NotNull @NotNull Easing easing) Two-keyframe transition fromfromtotowith the given easing applied across the segment. -
pulse
@NotNull public static <T> @NotNull Transition<T> pulse(@NotNull T start, @NotNull T peak, @NotNull T end, @NotNull @NotNull Interpolator<T> interpolator, int durationTicks, @NotNull @NotNull Easing in, @NotNull @NotNull Easing out) Three-keyframe pulse:start→peak(at t=0.5) →end, withineasing on the rise andouteasing on the fall.
-