Class Transition<T>

java.lang.Object
me.deecaad.core.transition.Transition<T>
Type Parameters:
T - The value type.

public final class Transition<T> extends Object
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 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 by evaluateAtTick(int) and playback helpers.
  • Method Details

    • getKeyframes

      @NotNull public @NotNull List<Keyframe<T>> getKeyframes()
      Returns:
      The non-null immutable sorted keyframe list.
    • getInterpolator

      @NotNull public @NotNull Interpolator<T> getInterpolator()
    • getDurationTicks

      public int getDurationTicks()
    • isStepped

      public boolean isStepped()
      Returns:
      true if the interpolator is stepped (no meaningful intermediate values).
    • evaluate

      @NotNull public T evaluate(double t)
      Evaluates the curve at normalized time t, clamped to [0, 1].
      Parameters:
      t - The normalized time.
      Returns:
      The non-null value.
    • evaluateAtTick

      @NotNull public T evaluateAtTick(int tick)
      Convenience: evaluates at tick / 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 returns value at every time.
    • lerp

      @NotNull public static <T> @NotNull Transition<T> lerp(@NotNull T from, @NotNull T to, @NotNull @NotNull Interpolator<T> interpolator, int durationTicks)
      Two-keyframe transition from from to to with Easing.LINEAR easing.
    • 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 from from to to with 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: startpeak (at t=0.5) → end, with in easing on the rise and out easing on the fall.