Package icyllis.modernui.animation
Class BezierInterpolator
java.lang.Object
icyllis.modernui.animation.BezierInterpolator
- All Implemented Interfaces:
TimeInterpolator
An interpolator that can traverse a Bezier curve that extends from
(0, 0)
to (1, 1)
. The x coordinate along the curve
is the input value and the output is the y coordinate of the line at that point.
See MotionEasingUtils
for commonly-used interpolators.
- Since:
- 3.12
-
Field Summary
Fields inherited from interface icyllis.modernui.animation.TimeInterpolator
ACCELERATE, ACCELERATE_DECELERATE, ANTICIPATE, ANTICIPATE_OVERSHOOT, BOUNCE, DECELERATE, DECELERATE_CUBIC, DECELERATE_QUINTIC, LINEAR, OVERSHOOT, SINE, VISCOUS_FLUID
-
Constructor Summary
ConstructorsConstructorDescriptionBezierInterpolator
(float controlX, float controlY) Create an interpolator for a quadratic Bezier curve.BezierInterpolator
(float controlX1, float controlY1, float controlX2, float controlY2) Create an interpolator for a cubic Bezier curve. -
Method Summary
Modifier and TypeMethodDescriptionstatic BezierInterpolator
createTwoCubic
(float controlX1, float controlY1, float controlX2, float controlY2, float controlX3, float controlY3, float controlX4, float controlY4, float controlX5, float controlY5) Create an interpolator for two cubic Bezier curves.float
getInterpolation
(float t) Using the curve in this interpolator that can be described asy = f(x)
, finds the y coordinate of the line givent
as the x coordinate.
-
Constructor Details
-
BezierInterpolator
public BezierInterpolator(float controlX, float controlY) Create an interpolator for a quadratic Bezier curve. The end points(0, 0)
and(1, 1)
are assumed.- Parameters:
controlX
- The x coordinate of the quadratic Bezier control point.controlY
- The y coordinate of the quadratic Bezier control point.
-
BezierInterpolator
public BezierInterpolator(float controlX1, float controlY1, float controlX2, float controlY2) Create an interpolator for a cubic Bezier curve. The end points(0, 0)
and(1, 1)
are assumed.- Parameters:
controlX1
- The x coordinate of the first control point of the cubic Bezier.controlY1
- The y coordinate of the first control point of the cubic Bezier.controlX2
- The x coordinate of the second control point of the cubic Bezier.controlY2
- The y coordinate of the second control point of the cubic Bezier.
-
-
Method Details
-
createTwoCubic
@NonNull public static BezierInterpolator createTwoCubic(float controlX1, float controlY1, float controlX2, float controlY2, float controlX3, float controlY3, float controlX4, float controlY4, float controlX5, float controlY5) Create an interpolator for two cubic Bezier curves. The end points(0, 0)
and(1, 1)
are assumed.The first cubic Bezier is formed by
(0, 0)
,(controlX1, controlY1)
,(controlX2, controlY2)
,(controlX3, controlY3)
; and the second cubic Bezier is formed by(controlX3, controlY3)
,(controlX4, controlY4)
,(controlX5, controlY5)
,(1, 1)
-
getInterpolation
public float getInterpolation(float t) Using the curve in this interpolator that can be described asy = f(x)
, finds the y coordinate of the line givent
as the x coordinate. Values less than 0 will always return 0 and values greater than 1 will always return 1.- Specified by:
getInterpolation
in interfaceTimeInterpolator
- Parameters:
t
- Treated as the x coordinate along the line.- Returns:
- The y coordinate of the Path along the line where x =
t
. - See Also:
-