public class Cubic

Known direct subclasses
MutableCubic

This is a Mutable version of Cubic, used mostly for performance critical paths so we can avoid creating new Cubics


This class holds the anchor and control point data for a single cubic Bézier curve, with anchor points (anchor0X, anchor0Y) and (anchor1X, anchor1Y) at either end and control points (control0X, control0Y) and (control1X, control1Y) determining the slope of the curve between the anchor points.

Summary

Public methods

static final @NonNull Cubic
circularArc(
    float centerX,
    float centerY,
    float x0,
    float y0,
    float x1,
    float y1
)

Generates a bezier curve that approximates a circular arc, with p0 and p1 as the starting and ending anchor points.

final @NonNull Cubic
div(float x)

Operator overload to enable dividing Cubics by a scalar value x, like "c0 / x"

final @NonNull Cubic
div(int x)

Operator overload to enable dividing Cubics by a scalar value x, like "c0 / x"

boolean
equals(Object other)
final float

The first anchor point x coordinate

final float

The first anchor point y coordinate

final float

The second anchor point x coordinate

final float

The second anchor point y coordinate

final float

The first control point x coordinate

final float

The first control point y coordinate

final float

The second control point x coordinate

final float

The second control point y coordinate

int
final @NonNull Cubic

Operator overload to enable adding Cubic objects together, like "c0 + c1"

final @NonNull Cubic

Utility function to reverse the control/anchor points for this curve.

final @NonNull Pair<@NonNull Cubic, @NonNull Cubic>
split(float t)

Returns two Cubics, created by splitting this curve at the given distance of t between the original starting and ending anchor points.

static final @NonNull Cubic
straightLine(float x0, float y0, float x1, float y1)

Generates a bezier curve that is a straight line between the given anchor points.

final @NonNull Cubic
times(float x)

Operator overload to enable multiplying Cubics by a scalar value x, like "c0 * x"

final @NonNull Cubic
times(int x)

Operator overload to enable multiplying Cubics by an Int scalar value x, like "c0 * x"

@NonNull String
final @NonNull Cubic

Transforms the points in this Cubic with the given PointTransformer and returns a new Cubic

Public methods

circularArc

Added in 1.0.1
public static final @NonNull Cubic circularArc(
    float centerX,
    float centerY,
    float x0,
    float y0,
    float x1,
    float y1
)

Generates a bezier curve that approximates a circular arc, with p0 and p1 as the starting and ending anchor points. The curve generated is the smallest of the two possible arcs around the entire 360-degree circle. Arcs of greater than 180 degrees should use more than one arc together. Note that p0 and p1 should be equidistant from the center.

div

Added in 1.0.1
public final @NonNull Cubic div(float x)

Operator overload to enable dividing Cubics by a scalar value x, like "c0 / x"

div

Added in 1.0.1
public final @NonNull Cubic div(int x)

Operator overload to enable dividing Cubics by a scalar value x, like "c0 / x"

equals

public boolean equals(Object other)

getAnchor0X

Added in 1.0.1
public final float getAnchor0X()

The first anchor point x coordinate

getAnchor0Y

Added in 1.0.1
public final float getAnchor0Y()

The first anchor point y coordinate

getAnchor1X

Added in 1.0.1
public final float getAnchor1X()

The second anchor point x coordinate

getAnchor1Y

Added in 1.0.1
public final float getAnchor1Y()

The second anchor point y coordinate

getControl0X

Added in 1.0.1
public final float getControl0X()

The first control point x coordinate

getControl0Y

Added in 1.0.1
public final float getControl0Y()

The first control point y coordinate

getControl1X

Added in 1.0.1
public final float getControl1X()

The second control point x coordinate

getControl1Y

Added in 1.0.1
public final float getControl1Y()

The second control point y coordinate

hashCode

public int hashCode()

plus

Added in 1.0.1
public final @NonNull Cubic plus(@NonNull Cubic o)

Operator overload to enable adding Cubic objects together, like "c0 + c1"

reverse

Added in 1.0.1
public final @NonNull Cubic reverse()

Utility function to reverse the control/anchor points for this curve.

split

Added in 1.0.1
public final @NonNull Pair<@NonNull Cubic, @NonNull Cubicsplit(float t)

Returns two Cubics, created by splitting this curve at the given distance of t between the original starting and ending anchor points.

straightLine

Added in 1.0.1
public static final @NonNull Cubic straightLine(float x0, float y0, float x1, float y1)

Generates a bezier curve that is a straight line between the given anchor points. The control points lie 1/3 of the distance from their respective anchor points.

times

Added in 1.0.1
public final @NonNull Cubic times(float x)

Operator overload to enable multiplying Cubics by a scalar value x, like "c0 * x"

times

Added in 1.0.1
public final @NonNull Cubic times(int x)

Operator overload to enable multiplying Cubics by an Int scalar value x, like "c0 * x"

toString

public @NonNull String toString()

transformed

Added in 1.0.1
public final @NonNull Cubic transformed(@NonNull PointTransformer f)

Transforms the points in this Cubic with the given PointTransformer and returns a new Cubic

Parameters
@NonNull PointTransformer f

The PointTransformer used to transform this Cubic