# Cubic

Artifact: [androidx.graphics:graphics-shapes](https://developer.android.com/jetpack/androidx/releases/graphics) [View Source](https://cs.android.com/search?q=file:androidx/graphics/shapes/Cubic.kt+class:androidx.graphics.shapes.Cubic) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

*** ** * ** ***


```
public class Cubic
```

<br />

Known direct subclasses [MutableCubic](https://developer.android.com/reference/androidx/graphics/shapes/MutableCubic)

|---|---|
| `https://developer.android.com/reference/androidx/graphics/shapes/MutableCubic` | This is a Mutable version of `https://developer.android.com/reference/androidx/graphics/shapes/Cubic`, used mostly for performance critical paths so we can avoid creating new `https://developer.android.com/reference/androidx/graphics/shapes/Cubic`s |

*** ** * ** ***

This class holds the anchor and control point data for a single cubic Bézier curve, with anchor points (`https://developer.android.com/reference/androidx/graphics/shapes/Cubic#anchor0X()`, `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#anchor0Y()`) and (`https://developer.android.com/reference/androidx/graphics/shapes/Cubic#anchor1X()`, `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#anchor1Y()`) at either end and control points (`https://developer.android.com/reference/androidx/graphics/shapes/Cubic#control0X()`, `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#control0Y()`) and (`https://developer.android.com/reference/androidx/graphics/shapes/Cubic#control1X()`, `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#control1Y()`) determining the slope of the curve between the anchor points.

## Summary

| ### Public methods |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/Cubic` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#circularArc(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)( 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 @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/Cubic` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#div(kotlin.Float)(float x)` Operator overload to enable dividing Cubics by a scalar value x, like "c0 / x" |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/Cubic` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#div(kotlin.Int)(int x)` Operator overload to enable dividing Cubics by a scalar value x, like "c0 / x" |
| `boolean` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final float` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#getAnchor0X()()` The first anchor point x coordinate |
| `final float` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#getAnchor0Y()()` The first anchor point y coordinate |
| `final float` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#getAnchor1X()()` The second anchor point x coordinate |
| `final float` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#getAnchor1Y()()` The second anchor point y coordinate |
| `final float` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#getControl0X()()` The first control point x coordinate |
| `final float` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#getControl0Y()()` The first control point y coordinate |
| `final float` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#getControl1X()()` The second control point x coordinate |
| `final float` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#getControl1Y()()` The second control point y coordinate |
| `int` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#hashCode()()` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/Cubic` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#plus(androidx.graphics.shapes.Cubic)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/Cubic o)` Operator overload to enable adding Cubic objects together, like "c0 + c1" |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/Cubic` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#reverse()()` Utility function to reverse the control/anchor points for this curve. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-pair/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/Cubic, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/Cubic>` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#split(kotlin.Float)(float t)` Returns two Cubics, created by splitting this curve at the given distance of `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#split(kotlin.Float)` between the original starting and ending anchor points. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/Cubic` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#straightLine(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)(float x0, float y0, float x1, float y1)` Generates a bezier curve that is a straight line between the given anchor points. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/Cubic` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#times(kotlin.Float)(float x)` Operator overload to enable multiplying Cubics by a scalar value x, like "c0 \* x" |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/Cubic` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#times(kotlin.Int)(int x)` Operator overload to enable multiplying Cubics by an Int scalar value x, like "c0 \* x" |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#toString()()` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/Cubic` | `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#transformed(androidx.graphics.shapes.PointTransformer)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/PointTransformer f)` Transforms the points in this `https://developer.android.com/reference/androidx/graphics/shapes/Cubic` with the given `https://developer.android.com/reference/androidx/graphics/shapes/PointTransformer` and returns a new `https://developer.android.com/reference/androidx/graphics/shapes/Cubic` |

## Public methods

### circularArc

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
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.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
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.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
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.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
public final float getAnchor0X()
```

The first anchor point x coordinate

### getAnchor0Y

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
public final float getAnchor0Y()
```

The first anchor point y coordinate

### getAnchor1X

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
public final float getAnchor1X()
```

The second anchor point x coordinate

### getAnchor1Y

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
public final float getAnchor1Y()
```

The second anchor point y coordinate

### getControl0X

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
public final float getControl0X()
```

The first control point x coordinate

### getControl0Y

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
public final float getControl0Y()
```

The first control point y coordinate

### getControl1X

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
public final float getControl1X()
```

The second control point x coordinate

### getControl1Y

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
public final float getControl1Y()
```

The second control point y coordinate

### hashCode

```
public int hashCode()
```

### plus

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
public final @NonNull Cubic plus(@NonNull Cubic o)
```

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

### reverse

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
public final @NonNull Cubic reverse()
```

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

### split

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

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

Returns two Cubics, created by splitting this curve at the given distance of `https://developer.android.com/reference/androidx/graphics/shapes/Cubic#split(kotlin.Float)` between the original starting and ending anchor points.

### straightLine

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
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.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
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.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
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.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

```
public final @NonNull Cubic transformed(@NonNull PointTransformer f)
```

Transforms the points in this `https://developer.android.com/reference/androidx/graphics/shapes/Cubic` with the given `https://developer.android.com/reference/androidx/graphics/shapes/PointTransformer` and returns a new `https://developer.android.com/reference/androidx/graphics/shapes/Cubic`

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/PointTransformer f` | The `https://developer.android.com/reference/androidx/graphics/shapes/PointTransformer` used to transform this `https://developer.android.com/reference/androidx/graphics/shapes/Cubic` |