Record Class Transition

java.lang.Object
java.lang.Record
net.ixdarklord.coolcatcanvas.api.armature.Transition
Record Components:
duration - seconds the blend takes; 0 cuts
easing - how the blend is paced (only named curves, Easings, can be sent from the server)

public record Transition(float duration, Easing easing, Transition.Mode mode) extends Record
How one animation gives way to the next: over how long, along which curve, and how the two meet.
Transition.crossfade(0.3F)                        // both move while they blend: walk into run
Transition.freeze(0.25F, Easing.CUBIC_OUT)        // the old pose holds still while the new one blends in
Transition.CUT                                    // no blend at all
A motion can carry its own (Motion.transition); otherwise its layer decides, by its rules or its default (see AnimLayer.transition). Immutable.
  • Field Details

    • DEFAULT

      public static final Transition DEFAULT
      What a layer uses when nothing else is set: a fifth of a second, crossfading, sine in-out.
    • CUT

      public static final Transition CUT
      Straight to the next animation.
    • STREAM_CODEC

      public static final net.minecraft.network.codec.StreamCodec<net.minecraft.network.FriendlyByteBuf, Transition> STREAM_CODEC
  • Constructor Details

    • Transition

      public Transition(float duration, Easing easing, Transition.Mode mode)
      Creates an instance of a Transition record class.
      Parameters:
      duration - the value for the duration record component
      easing - the value for the easing record component
      mode - the value for the mode record component
  • Method Details

    • crossfade

      public static Transition crossfade(float seconds)
      Both animations keep moving while one blends into the other.
    • crossfade

      public static Transition crossfade(float seconds, Easing easing)
    • freeze

      public static Transition freeze(float seconds)
      The old animation stops where it is and the new one blends in from that still pose: seamless even when the old one is cut off mid-swing, and never a mix of two motions at once.
    • freeze

      public static Transition freeze(float seconds, Easing easing)
    • withDuration

      public Transition withDuration(float seconds)
    • withEasing

      public Transition withEasing(Easing easing)
    • blends

      public boolean blends()
      Whether there is a blend at all.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • duration

      public float duration()
      Returns the value of the duration record component.
      Returns:
      the value of the duration record component
    • easing

      public Easing easing()
      Returns the value of the easing record component.
      Returns:
      the value of the easing record component
    • mode

      public Transition.Mode mode()
      Returns the value of the mode record component.
      Returns:
      the value of the mode record component