Record Class Curve

java.lang.Object
java.lang.Record
net.ixdarklord.coolcatcanvas.api.client.vfx.Curve
Record Components:
in - the easing of the first half
out - the easing of the second half

public record Curve(float start, float middle, float end, Easing in, Easing out) extends Record
A value over a lifetime, in three points: it eases from start to middle over the first half, then from middle to end over the second. A camera shake uses one for its strength, which is what lets it swell and die away instead of starting and stopping dead.

 Curve.constant(0.25F)                       // always 0.25
 Curve.of(0.0F, 1.0F)                        // grows, linearly
 Curve.of(0.0F, 1.0F, 0.0F)                  // in, then out again
 Curve.of(0.2F, 0.6F, 0.0F).easing(Easing.EXPO_OUT, Easing.SINE_IN)   // bursts open, then drifts shut
 
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Curve
     
    static final Curve
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Curve(float start, float middle, float end, Easing in, Easing out)
    Creates an instance of a Curve record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    at(float progress)
    The value at a progress through the lifetime, 0 to 1 (clamped).
    static Curve
    constant(float value)
     
    easing(Easing easing)
    This curve with both halves eased the same way.
    easing(Easing in, Easing out)
     
    float
    end()
    Returns the value of the end record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    in()
    Returns the value of the in record component.
    float
    Returns the value of the middle record component.
    static Curve
    of(float start, float end)
    From start to end, passing half way between them at half the lifetime.
    static Curve
    of(float start, float middle, float end)
     
    out()
    Returns the value of the out record component.
    scaled(float factor)
    This curve with every point multiplied.
    float
    Returns the value of the start record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • ZERO

      public static final Curve ZERO
    • ONE

      public static final Curve ONE
  • Constructor Details

    • Curve

      public Curve(float start, float middle, float end, Easing in, Easing out)
      Creates an instance of a Curve record class.
      Parameters:
      start - the value for the start record component
      middle - the value for the middle record component
      end - the value for the end record component
      in - the value for the in record component
      out - the value for the out record component
  • Method Details

    • constant

      public static Curve constant(float value)
    • of

      public static Curve of(float start, float end)
      From start to end, passing half way between them at half the lifetime.
    • of

      public static Curve of(float start, float middle, float end)
    • easing

      public Curve easing(Easing easing)
      This curve with both halves eased the same way.
    • easing

      public Curve easing(Easing in, Easing out)
    • scaled

      public Curve scaled(float factor)
      This curve with every point multiplied.
    • at

      public float at(float progress)
      The value at a progress through the lifetime, 0 to 1 (clamped).
    • 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 '=='.
      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.
    • start

      public float start()
      Returns the value of the start record component.
      Returns:
      the value of the start record component
    • middle

      public float middle()
      Returns the value of the middle record component.
      Returns:
      the value of the middle record component
    • end

      public float end()
      Returns the value of the end record component.
      Returns:
      the value of the end record component
    • in

      public Easing in()
      Returns the value of the in record component.
      Returns:
      the value of the in record component
    • out

      public Easing out()
      Returns the value of the out record component.
      Returns:
      the value of the out record component