# Cubic

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/graphics/shapes/Cubic "View this page in Java")
Common/AllAndroid/JVM
  - Cmn  

  ```
  open class Cubic
```  
Known direct subclasses  
[MutableCubic](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/MutableCubic)  

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

*** ** * ** ***

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

## Summary

|                             ### Public companion functions                             |
|----------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----|
| [Cubic](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic) | [circularArc](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#circularArc(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float))`(` ` centerX: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`,` ` centerY: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`,` ` x0: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`,` ` y0: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`,` ` x1: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`,` ` y1: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) `)` Generates a bezier curve that approximates a circular arc, with p0 and p1 as the starting and ending anchor points. | Cmn |
| [Cubic](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic) | [straightLine](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#straightLine(kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float))`(x0: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`, y0: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`, x1: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`, y1: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Generates a bezier curve that is a straight line between the given anchor points.                                                                                                                                                                                                                                                                       | Cmn |

|                                                                                                                        ### Public functions                                                                                                                         |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----|
| `operator `[Cubic](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic)                                                                                                                                                                   | [div](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#div(kotlin.Float))`(x: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Operator overload to enable dividing Cubics by a scalar value x, like "c0 / x"                                                                                                                                                                                                                                                                                                                                                 | Cmn |
| `operator `[Cubic](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic)                                                                                                                                                                   | [div](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#div(kotlin.Int))`(x: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Operator overload to enable dividing Cubics by a scalar value x, like "c0 / x"                                                                                                                                                                                                                                                                                                                                                       | Cmn |
| `open operator `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                                                                                                                                                 | [equals](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#equals(kotlin.Any))`(other: `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?)`                                                                                                                                                                                                                                                                                                                                                                                                                           | Cmn |
| `open `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                                                                                                  | [hashCode](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#hashCode())`()`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | Cmn |
| `operator `[Cubic](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic)                                                                                                                                                                   | [plus](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#plus(androidx.graphics.shapes.Cubic))`(o: `[Cubic](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic)`)` Operator overload to enable adding Cubic objects together, like "c0 + c1"                                                                                                                                                                                                                                                                                                                           | Cmn |
| [Cubic](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic)                                                                                                                                                                              | [reverse](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#reverse())`()` Utility function to reverse the control/anchor points for this curve.                                                                                                                                                                                                                                                                                                                                                                                                                                                  | Cmn |
| [Pair](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-pair/index.html)`<`[Cubic](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic)`, `[Cubic](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic)`>` | [split](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#split(kotlin.Float))`(t: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Returns two Cubics, created by splitting this curve at the given distance of[t](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#split(kotlin.Float))between the original starting and ending anchor points.                                                                                                                                                                                  | Cmn |
| `operator `[Cubic](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic)                                                                                                                                                                   | [times](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#times(kotlin.Float))`(x: `[Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)`)` Operator overload to enable multiplying Cubics by a scalar value x, like "c0 \* x"                                                                                                                                                                                                                                                                                                                                         | Cmn |
| `operator `[Cubic](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic)                                                                                                                                                                   | [times](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#times(kotlin.Int))`(x: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Operator overload to enable multiplying Cubics by an Int scalar value x, like "c0 \* x"                                                                                                                                                                                                                                                                                                                                          | Cmn |
| `open `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)                                                                                                                                                                            | [toString](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#toString())`()`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | Cmn |
| [Cubic](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic)                                                                                                                                                                              | [transformed](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#transformed(androidx.graphics.shapes.PointTransformer))`(f: `[PointTransformer](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/PointTransformer)`)` Transforms the points in this[Cubic](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic)with the given[PointTransformer](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/PointTransformer)and returns a new[Cubic](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic) | Cmn |

|                              ### Public properties                              |
|---------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------|-----|
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [anchor0X](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#anchor0X()) The first anchor point x coordinate     | Cmn |
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [anchor0Y](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#anchor0Y()) The first anchor point y coordinate     | Cmn |
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [anchor1X](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#anchor1X()) The second anchor point x coordinate    | Cmn |
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [anchor1Y](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#anchor1Y()) The second anchor point y coordinate    | Cmn |
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [control0X](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#control0X()) The first control point x coordinate  | Cmn |
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [control0Y](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#control0Y()) The first control point y coordinate  | Cmn |
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [control1X](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#control1X()) The second control point x coordinate | Cmn |
| [Float](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html) | [control1Y](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic#control1Y()) The second control point y coordinate | Cmn |

## Public companion functions

### circularArc

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

```
fun circularArc(
    centerX: Float,
    centerY: Float,
    x0: Float,
    y0: Float,
    x1: Float,
    y1: Float
): Cubic
```

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.  

### straightLine

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

```
fun straightLine(x0: Float, y0: Float, x1: Float, y1: Float): Cubic
```

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.

## Public functions

### div

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

```
operator fun div(x: Float): Cubic
```

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

### div

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

```
operator fun div(x: Int): Cubic
```

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

### equals

Cmn  

```
open operator fun equals(other: Any?): Boolean
```  

### hashCode

Cmn  

```
open fun hashCode(): Int
```  

### plus

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

```
operator fun plus(o: Cubic): Cubic
```

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

### reverse

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

```
fun reverse(): Cubic
```

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

### split

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

```
fun split(t: Float): Pair<Cubic, Cubic>
```

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

### times

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

```
operator fun times(x: Float): Cubic
```

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

### times

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

```
operator fun times(x: Int): Cubic
```

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

### toString

Cmn  

```
open fun toString(): String
```  

### transformed

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

```
fun transformed(f: PointTransformer): Cubic
```

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

|                                                    Parameters                                                     |
|-------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `f: `[PointTransformer](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/PointTransformer) | The[PointTransformer](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/PointTransformer)used to transform this[Cubic](https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic) |

## Public properties

### anchor0X

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

```
val anchor0X: Float
```

The first anchor point x coordinate  

### anchor0Y

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

```
val anchor0Y: Float
```

The first anchor point y coordinate  

### anchor1X

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

```
val anchor1X: Float
```

The second anchor point x coordinate  

### anchor1Y

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

```
val anchor1Y: Float
```

The second anchor point y coordinate  

### control0X

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

```
val control0X: Float
```

The first control point x coordinate  

### control0Y

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

```
val control0Y: Float
```

The first control point y coordinate  

### control1X

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

```
val control1X: Float
```

The second control point x coordinate  

### control1Y

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

```
val control1Y: Float
```

The second control point y coordinate