Record Class CubicBezier

java.lang.Object
java.lang.Record
top.girlkisser.lazuli.api.mathematics.CubicBezier
Record Components:
start - The starting position.
control1 - The first control point.
control2 - The second control point.
end - The ending position.

public record CubicBezier(org.joml.Vector2f start, org.joml.Vector2f control1, org.joml.Vector2f control2, org.joml.Vector2f end) extends Record
A cubic Bézier curve implementation.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.serialization.Codec<CubicBezier>
    A codec for a cubic Bézier curve with the following format:
    { "start": { "x": 0.0, "y": 0.0 }, "control1": { "x": 0.25, "y": 0.5 }, "control2": { "x": 0.75, "y": 0.2 }, "end": { "x": 1.0, "y": 1.0 } }
    static final com.mojang.serialization.Codec<CubicBezier>
    A codec for a cubic Bézier curve with the following format:
    [ { "x": 0.0, "y": 0.0 }, { "x": 0.25, "y": 0.5 }, { "x": 0.75, "y": 0.2 }, { "x": 1.0, "y": 1.0 } ]
    static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,CubicBezier>
     
    static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,CubicBezier>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    CubicBezier(float control1X, float control1Y, float control2X, float control2Y)
    Create a cubic Bézier curve using the provided coordinates for control points.
    CubicBezier(float startX, float startY, float control1X, float control1Y, float control2X, float control2Y, float endX, float endY)
    Create a cubic Bézier curve using the provided coordinates for points.
    CubicBezier(org.joml.Vector2f control1, org.joml.Vector2f control2)
    Create a cubic Bézier curve using the provided control points.
    CubicBezier(org.joml.Vector2f start, org.joml.Vector2f control1, org.joml.Vector2f control2, org.joml.Vector2f end)
    Creates an instance of a CubicBezier record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.joml.Vector2f
    Returns the value of the control1 record component.
    org.joml.Vector2f
    Returns the value of the control2 record component.
    org.joml.Vector2f
    end()
    Returns the value of the end record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    List<org.joml.Vector2f>
    getPoints(float resolution)
    Get a list of points from 0 to 1 with `resolution` steps.
    final int
    Returns a hash code value for this object.
    org.joml.Vector2f
    sample(float t)
    Get the point for the given `t` value.
    org.joml.Vector2f
    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

    • CODEC

      public static final com.mojang.serialization.Codec<CubicBezier> CODEC
      A codec for a cubic Bézier curve with the following format:
      { "start": { "x": 0.0, "y": 0.0 }, "control1": { "x": 0.25, "y": 0.5 }, "control2": { "x": 0.75, "y": 0.2 }, "end": { "x": 1.0, "y": 1.0 } }
    • STREAM_CODEC

      public static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,CubicBezier> STREAM_CODEC
    • LIST_CODEC

      public static final com.mojang.serialization.Codec<CubicBezier> LIST_CODEC
      A codec for a cubic Bézier curve with the following format:
      [ { "x": 0.0, "y": 0.0 }, { "x": 0.25, "y": 0.5 }, { "x": 0.75, "y": 0.2 }, { "x": 1.0, "y": 1.0 } ]
    • LIST_STREAM_CODEC

      public static final net.minecraft.network.codec.StreamCodec<io.netty.buffer.ByteBuf,CubicBezier> LIST_STREAM_CODEC
  • Constructor Details

    • CubicBezier

      public CubicBezier(org.joml.Vector2f control1, org.joml.Vector2f control2)
      Create a cubic Bézier curve using the provided control points. The start and end points are 0,0 and 1,1 respectively.
      Parameters:
      control1 - The first control point.
      control2 - The second control point.
    • CubicBezier

      public CubicBezier(float control1X, float control1Y, float control2X, float control2Y)
      Create a cubic Bézier curve using the provided coordinates for control points. The start and end points are 0,0 and 1,1 respectively.
      Parameters:
      control1X - The first control point's X coordinate.
      control1Y - The first control point's Y coordinate.
      control2X - The second control point's X coordinate.
      control2Y - The second control point's Y coordinate.
    • CubicBezier

      public CubicBezier(float startX, float startY, float control1X, float control1Y, float control2X, float control2Y, float endX, float endY)
      Create a cubic Bézier curve using the provided coordinates for points.
      Parameters:
      startX - The start point's X coordinate.
      startY - The start point's Y coordinate.
      control1X - The first control point's X coordinate.
      control1Y - The first control point's Y coordinate.
      control2X - The second control point's X coordinate.
      control2Y - The second control point's Y coordinate.
      endX - The end point's X coordinate.
      endY - The end point's Y coordinate.
    • CubicBezier

      public CubicBezier(org.joml.Vector2f start, org.joml.Vector2f control1, org.joml.Vector2f control2, org.joml.Vector2f end)
      Creates an instance of a CubicBezier record class.
      Parameters:
      start - the value for the start record component
      control1 - the value for the control1 record component
      control2 - the value for the control2 record component
      end - the value for the end record component
  • Method Details

    • sample

      public org.joml.Vector2f sample(float t)
      Get the point for the given `t` value.
      Parameters:
      t - The "progress" of the curve, from 0 to 1.
      Returns:
      The point at the given `t` value.
    • getPoints

      public List<org.joml.Vector2f> getPoints(float resolution)
      Get a list of points from 0 to 1 with `resolution` steps.
      Parameters:
      resolution - The amount of steps, or "resolution" of the points.
      Returns:
      The list of points.
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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 org.joml.Vector2f start()
      Returns the value of the start record component.
      Returns:
      the value of the start record component
    • control1

      public org.joml.Vector2f control1()
      Returns the value of the control1 record component.
      Returns:
      the value of the control1 record component
    • control2

      public org.joml.Vector2f control2()
      Returns the value of the control2 record component.
      Returns:
      the value of the control2 record component
    • end

      public org.joml.Vector2f end()
      Returns the value of the end record component.
      Returns:
      the value of the end record component