# RoundedPolygon

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/RoundedPolygon.kt+class:androidx.graphics.shapes.RoundedPolygon) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/graphics#1.0.0)

*** ** * ** ***


```
public final class RoundedPolygon
```

<br />

*** ** * ** ***

The RoundedPolygon class allows simple construction of polygonal shapes with optional rounding at the vertices. Polygons can be constructed with either the number of vertices desired or an ordered list of vertices.

## Summary

| ### Nested types |
|---|
| `public static class https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon.Companion` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull float[]` | `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon#calculateBounds(kotlin.FloatArray,kotlin.Boolean)(@https://developer.android.com/reference/androidx/annotation/NonNull float[] bounds, boolean approximate)` Calculates the axis-aligned bounds of the object. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull float[]` | `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon#calculateMaxBounds(kotlin.FloatArray)(@https://developer.android.com/reference/androidx/annotation/NonNull float[] bounds)` Like `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon#calculateBounds(kotlin.FloatArray,kotlin.Boolean)`, this function calculates the axis-aligned bounds of the object and returns that rectangle. |
| `boolean` | `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `final float` | `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon#getCenterX()()` |
| `final float` | `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon#getCenterY()()` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@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/RoundedPolygon#getCubics()()` A flattened version of the `https://developer.android.com/reference/androidx/graphics/shapes/Feature`s, as a List. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/Feature>` | `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon#getFeatures()()` |
| `int` | `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon#hashCode()()` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon` | `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon#normalized()()` Creates a new RoundedPolygon, moving and resizing this one, so it's completely inside the (0, 0) -\> (1, 1) square, centered if there extra space in one direction |
| `@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/RoundedPolygon#toString()()` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon` | `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon#transformed(androidx.graphics.shapes.PointTransformer)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/PointTransformer f)` Transforms (scales/translates/etc.) this `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon` with the given `https://developer.android.com/reference/androidx/graphics/shapes/PointTransformer` and returns a new `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon`. |

| ### Extension functions |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Path.html` | `https://developer.android.com/reference/androidx/graphics/shapes/ShapesKt.https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon#(androidx.graphics.shapes.RoundedPolygon).toPath(android.graphics.Path)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Path.html path)` Gets a `https://developer.android.com/reference/android/graphics/Path.html` representation for a `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon` shape. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon` | `https://developer.android.com/reference/androidx/graphics/shapes/ShapesKt.https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon#(androidx.graphics.shapes.RoundedPolygon).transformed(android.graphics.Matrix)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon receiver, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Matrix.html matrix )` Transforms a `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon` by the given matrix. |

## Public methods

### calculateBounds

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

```
public final @NonNull float[] calculateBounds(@NonNull float[] bounds, boolean approximate)
```

Calculates the axis-aligned bounds of the object.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull float[] bounds` | a buffer to hold the results. If not supplied, a temporary buffer will be created. |
| `boolean approximate` | when true, uses a faster calculation to create the bounding box based on the min/max values of all anchor and control points that make up the shape. Default value is true. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull float[]` | The axis-aligned bounding box for this object, where the rectangles left, top, right, and bottom values will be stored in entries 0, 1, 2, and 3, in that order. |

### calculateMaxBounds

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

```
public final @NonNull float[] calculateMaxBounds(@NonNull float[] bounds)
```

Like `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon#calculateBounds(kotlin.FloatArray,kotlin.Boolean)`, this function calculates the axis-aligned bounds of the object and returns that rectangle. But this function determines the max dimension of the shape (by calculating the distance from its center to the start and midpoint of each curve) and returns a square which can be used to hold the object in any rotation. This function can be used, for example, to calculate the max size of a UI element meant to hold this shape in any rotation.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull float[] bounds` | a buffer to hold the results. If not supplied, a temporary buffer will be created. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull float[]` | The axis-aligned max bounding box for this object, where the rectangles left, top, right, and bottom values will be stored in entries 0, 1, 2, and 3, in that order. |

### equals

```
public boolean equals(Object other)
```

### getCenterX

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

```
public final float getCenterX()
```

### getCenterY

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

```
public final float getCenterY()
```

### getCubics

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

```
public final @NonNull List<@NonNull Cubic> getCubics()
```

A flattened version of the `https://developer.android.com/reference/androidx/graphics/shapes/Feature`s, as a List.

### getFeatures

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

```
public final @NonNull List<@NonNull Feature> getFeatures()
```

### hashCode

```
public int hashCode()
```

### normalized

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

```
public final @NonNull RoundedPolygon normalized()
```

Creates a new RoundedPolygon, moving and resizing this one, so it's completely inside the (0, 0) -\> (1, 1) square, centered if there extra space in one direction

### 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 RoundedPolygon transformed(@NonNull PointTransformer f)
```

Transforms (scales/translates/etc.) this `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon` with the given `https://developer.android.com/reference/androidx/graphics/shapes/PointTransformer` and returns a new `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon`. This is a low level API and there should be more platform idiomatic ways to transform a `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon` provided by the platform specific wrapper.

| 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/RoundedPolygon` |

## Extension functions

### ShapesKt.toPath

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/Shapes.android.kt+function:toPath)

```
public final @NonNull Path ShapesKt.toPath(@NonNull RoundedPolygon receiver, @NonNull Path path)
```

Gets a `https://developer.android.com/reference/android/graphics/Path.html` representation for a `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon` shape. Note that there is some rounding happening (to the nearest thousandth), to work around rendering artifacts introduced by some points being just slightly off from each other (far less than a pixel). This also allows for a more optimal path, as redundant curves (usually a single point) can be detected and not added to the resulting path.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Path.html path` | an optional `https://developer.android.com/reference/android/graphics/Path.html` object which, if supplied, will avoid the function having to create a new `https://developer.android.com/reference/android/graphics/Path.html` object |

### ShapesKt.transformed

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/Shapes.android.kt+function:transformed)

```
public final @NonNull RoundedPolygon ShapesKt.transformed(
    @NonNull RoundedPolygon receiver,
    @NonNull Matrix matrix
)
```

Transforms a `https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon` by the given matrix.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Matrix.html matrix` | The matrix by which the polygon is to be transformed |