Record Class EaseFunction.CubicBezier
java.lang.Object
java.lang.Record
net.minestom.server.utils.EaseFunction.CubicBezier
- Record Components:
x1- the x coordinate of the first control point, between 0 and 1 inclusivey1- the y coordinate of the first control pointx2- the x coordinate of the second control point, between 0 and 1 inclusivey2- the y coordinate of the second control point
- All Implemented Interfaces:
EaseFunction
- Enclosing interface:
EaseFunction
public static record EaseFunction.CubicBezier(float x1, float y1, float x2, float y2)
extends Record
implements EaseFunction
A cubic bezier ease from (0, 0) to (1, 1), shaped by the control points (x1, y1) and (x2, y2).
Sampling treats the input as an x coordinate, finds the point of the curve with that x, and returns its y coordinate. Both x coordinates must be between 0 and 1 inclusive, which keeps x from decreasing along the curve so that each input has one output. The y coordinates are unbounded, and values outside 0 to 1 make the ease overshoot.
CODEC reads and writes the control points as {"cubic_bezier": [x1, y1, x2, y2]}. Decoding returns a
Result.Error when x1 or x2 is outside 0 to 1.
-
Nested Class Summary
Nested classes/interfaces inherited from interface EaseFunction
EaseFunction.CubicBezier -
Field Summary
FieldsFields inherited from interface EaseFunction
CONSTANT, IN_BACK, IN_CIRC, IN_CUBIC, IN_ELASTIC, IN_EXPO, IN_OUT_BACK, IN_OUT_CIRC, IN_OUT_CUBIC, IN_OUT_EXPO, IN_OUT_QUAD, IN_OUT_QUART, IN_OUT_QUINT, IN_OUT_SINE, IN_QUAD, IN_QUART, IN_QUINT, IN_SINE, LINEAR, NAMED_BY_KEY, NAMED_BY_VALUE, OUT_BACK, OUT_CIRC, OUT_CUBIC, OUT_EXPO, OUT_QUAD, OUT_QUART, OUT_QUINT, OUT_SINE -
Constructor Summary
ConstructorsConstructorDescriptionCubicBezier(float[] controlPoints) Deprecated.CubicBezier(float x1, float y1, float x2, float y2) Creates a cubic bezier ease from its control points. -
Method Summary
Modifier and TypeMethodDescriptionfloat[]final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.floatsample(float x) final StringtoString()Returns a string representation of this record class.floatx1()Returns the value of thex1record component.floatx2()Returns the value of thex2record component.floaty1()Returns the value of they1record component.floaty2()Returns the value of they2record component.
-
Field Details
-
CODEC
-
-
Constructor Details
-
CubicBezier
public CubicBezier(float x1, float y1, float x2, float y2) Creates a cubic bezier ease from its control points.- Throws:
IllegalArgumentException- if x1 or x2 is outside 0 to 1
-
CubicBezier
Deprecated.useCubicBezier(float, float, float, float)insteadCreates a cubic bezier ease from an array holding x1, y1, x2, and y2 in that order.- Parameters:
controlPoints- the control points, must have a length of 4- Throws:
IllegalArgumentException- if the array length is not 4, or if x1 or x2 is outside 0 to 1
-
-
Method Details
-
controlPoints
Returns the control points as a new array holding x1, y1, x2, and y2 in that order.- Returns:
- a new array of the control points
-
sample
public float sample(float x) - Specified by:
samplein interfaceEaseFunction
-
toString
-
hashCode
-
equals
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 thecomparemethod from their corresponding wrapper classes. -
x1
-
y1
-
x2
-
y2
-
CubicBezier(float, float, float, float)instead