# ShapePath

[View Source](https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/shape/ShapePath.java)

*** ** * ** ***


```
public class ShapePath
```

<br />

*** ** * ** ***

Represents the descriptive path of a shape. Path segments are stored in sequence so that transformations can be applied to them when the android.graphics.Path is produced by the `https://developer.android.com/reference/com/google/android/material/shape/MaterialShapeDrawable`.

## Summary

| ### Nested types |
|---|
| `public class https://developer.android.com/reference/com/google/android/material/shape/ShapePath.PathArcOperation extends https://developer.android.com/reference/com/google/android/material/shape/ShapePath.PathOperation` Path arc operation. |
| `public class https://developer.android.com/reference/com/google/android/material/shape/ShapePath.PathCubicOperation extends https://developer.android.com/reference/com/google/android/material/shape/ShapePath.PathOperation` Path cubic operation. |
| `public class https://developer.android.com/reference/com/google/android/material/shape/ShapePath.PathLineOperation extends https://developer.android.com/reference/com/google/android/material/shape/ShapePath.PathOperation` Straight line operation. |
| `public abstract class https://developer.android.com/reference/com/google/android/material/shape/ShapePath.PathOperation` Interface for a path operation to be appended to the operations list. |
| `public class https://developer.android.com/reference/com/google/android/material/shape/ShapePath.PathQuadOperation extends https://developer.android.com/reference/com/google/android/material/shape/ShapePath.PathOperation` Path quad operation. |

| ### Public fields |
|---|---|
| `float` | `https://developer.android.com/reference/com/google/android/material/shape/ShapePath#currentShadowAngle()` **This field is deprecated.** Use the class methods to interact with this field so internal state can be \* maintained. <br /> |
| `float` | `https://developer.android.com/reference/com/google/android/material/shape/ShapePath#endShadowAngle()` **This field is deprecated.** Use the class methods to interact with this field so internal state can be \* maintained. <br /> |
| `float` | `https://developer.android.com/reference/com/google/android/material/shape/ShapePath#endX()` **This field is deprecated.** Use the class methods to interact with this field so internal state can be maintained. <br /> |
| `float` | `https://developer.android.com/reference/com/google/android/material/shape/ShapePath#endY()` **This field is deprecated.** Use the class methods to interact with this field so internal state can be maintained. <br /> |
| `float` | `https://developer.android.com/reference/com/google/android/material/shape/ShapePath#startX()` **This field is deprecated.** Use the class methods to interact with this field so internal state can be maintained. <br /> |
| `float` | `https://developer.android.com/reference/com/google/android/material/shape/ShapePath#startY()` **This field is deprecated.** Use the class methods to interact with this field so internal state can be maintained. <br /> |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/com/google/android/material/shape/ShapePath#ShapePath()()` |
| `https://developer.android.com/reference/com/google/android/material/shape/ShapePath#ShapePath(float,float)(float startX, float startY)` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/shape/ShapePath#addArc(float,float,float,float,float,float)( float left, float top, float right, float bottom, float startAngle, float sweepAngle )` Add an arc to the ShapePath. |
| `void` | `https://developer.android.com/reference/com/google/android/material/shape/ShapePath#applyToPath(Matrix,Path)(Matrix transform, Path path)` Apply the ShapePath sequence to a android.graphics.Path under a matrix transform. |
| `void` | `https://developer.android.com/reference/com/google/android/material/shape/ShapePath#cubicToPoint(float,float,float,float,float,float)( float controlX1, float controlY1, float controlX2, float controlY2, float toX, float toY )` Add a cubic to the ShapePath. |
| `void` | `https://developer.android.com/reference/com/google/android/material/shape/ShapePath#lineTo(float,float)(float x, float y)` Add a line to the ShapePath. |
| `void` | `https://developer.android.com/reference/com/google/android/material/shape/ShapePath#lineTo(float,float,float,float)(float x1, float y1, float x2, float y2)` Add two connected segments to the ShapePath. |
| `void` | `https://developer.android.com/reference/com/google/android/material/shape/ShapePath#quadToPoint(float,float,float,float)(float controlX, float controlY, float toX, float toY)` Add a quad to the ShapePath. |
| `void` | `https://developer.android.com/reference/com/google/android/material/shape/ShapePath#reset(float,float)(float startX, float startY)` Resets the ShapePath using a default shadow. |
| `void` | `https://developer.android.com/reference/com/google/android/material/shape/ShapePath#reset(float,float,float,float)( float startX, float startY, float shadowStartAngle, float shadowSweepAngle )` Resets fields given the provided assignment parameters. |

## Public fields

### currentShadowAngle

```
public float currentShadowAngle
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use the class methods to interact with this field so internal state can be \* maintained.

The angle of the start of the last drawn shadow. Changes internally. Do not change.

### endShadowAngle

```
public float endShadowAngle
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use the class methods to interact with this field so internal state can be \* maintained.

The angle at the end of the final shadow. Changes internally. Do not change.

### endX

```
public float endX
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use the class methods to interact with this field so internal state can be maintained.

The x coordinate for the current end of the path given the previously applied transformation. Changes internally. Do not change.

### endY

```
public float endY
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use the class methods to interact with this field so internal state can be maintained.

The y coordinate for the current end of the path given the previously applied transformation. Changes internally. Do not change.

### startX

```
public float startX
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use the class methods to interact with this field so internal state can be maintained.

The x coordinate for the start of the path. Does not change. Do not change.

### startY

```
public float startY
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use the class methods to interact with this field so internal state can be maintained.

The y coordinate for the start of the path. Does not change. Do not change.

## Public constructors

### ShapePath

```
public ShapePath()
```

### ShapePath

```
public ShapePath(float startX, float startY)
```

## Public methods

### addArc

```
public void addArc(
    float left,
    float top,
    float right,
    float bottom,
    float startAngle,
    float sweepAngle
)
```

Add an arc to the ShapePath.

| Parameters |
|---|---|
| `float left` | the X coordinate of the left side of the rectangle containing the arc oval. |
| `float top` | the Y coordinate of the top of the rectangle containing the arc oval. |
| `float right` | the X coordinate of the right side of the rectangle containing the arc oval. |
| `float bottom` | the Y coordinate of the bottom of the rectangle containing the arc oval. |
| `float startAngle` | start angle of the arc. |
| `float sweepAngle` | sweep angle of the arc. |

### applyToPath

```
public void applyToPath(Matrix transform, Path path)
```

Apply the ShapePath sequence to a android.graphics.Path under a matrix transform.

| Parameters |
|---|---|
| `Matrix transform` | the matrix transform under which this ShapePath is applied |
| `Path path` | the path to which this ShapePath is applied |

### cubicToPoint

```
public void cubicToPoint(
    float controlX1,
    float controlY1,
    float controlX2,
    float controlY2,
    float toX,
    float toY
)
```

Add a cubic to the ShapePath.

Note: This operation will not draw compatibility shadows. This means no shadow will be drawn on API \<21 and a shadow will only be drawn on API \<29 if the final path is convex.

| Parameters |
|---|---|
| `float controlX1` | the 1st control point x of the arc. |
| `float controlY1` | the 1st control point y of the arc. |
| `float controlX2` | the 2nd control point x of the arc. |
| `float controlY2` | the 2nd control point y of the arc. |
| `float toX` | the end x of the arc. |
| `float toY` | the end y of the arc. |

### lineTo

```
public void lineTo(float x, float y)
```

Add a line to the ShapePath.

| Parameters |
|---|---|
| `float x` | the x to which the line should be drawn. |
| `float y` | the y to which the line should be drawn. |

### lineTo

```
public void lineTo(float x1, float y1, float x2, float y2)
```

Add two connected segments to the ShapePath. This is equivalent to call `https://developer.android.com/reference/com/google/android/material/shape/ShapePath#lineTo(float,float)` twice. If an inner corner is formed, this can also draw the compat shadow without overlapping.

### quadToPoint

```
public void quadToPoint(float controlX, float controlY, float toX, float toY)
```

Add a quad to the ShapePath.

Note: This operation will not draw compatibility shadows. This means no shadow will be drawn on API \<21 and a shadow will only be drawn on API \<29 if the final path is convex.

| Parameters |
|---|---|
| `float controlX` | the control point x of the arc. |
| `float controlY` | the control point y of the arc. |
| `float toX` | the end x of the arc. |
| `float toY` | the end y of the arc. |

### reset

```
public void reset(float startX, float startY)
```

Resets the ShapePath using a default shadow. `https://developer.android.com/reference/com/google/android/material/shape/ShapePath#reset(float,float,float,float)`.

### reset

```
public void reset(
    float startX,
    float startY,
    float shadowStartAngle,
    float shadowSweepAngle
)
```

Resets fields given the provided assignment parameters.