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

*** ** * ** ***

Common/AllAndroid/JVM
- Cmn

  ```
  class RoundedPolygon
  ```

*** ** * ** ***

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 |
|---|
| `object https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon.Companion` |

| ### Public functions |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon#calculateBounds(kotlin.FloatArray,kotlin.Boolean)(bounds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html, approximate: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` Calculates the axis-aligned bounds of the object. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon#calculateMaxBounds(kotlin.FloatArray)(bounds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html)` Like `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon#calculateBounds(kotlin.FloatArray,kotlin.Boolean)`, this function calculates the axis-aligned bounds of the object and returns that rectangle. | Cmn |
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon#hashCode()()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon` | `https://developer.android.com/reference/kotlin/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 | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon#toString()()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon` | `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon#transformed(androidx.graphics.shapes.PointTransformer)(f: https://developer.android.com/reference/kotlin/androidx/graphics/shapes/PointTransformer)` Transforms (scales/translates/etc.) this `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon` with the given `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/PointTransformer` and returns a new `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon`. | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon#centerX()` | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon#centerY()` | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Cubic>` | `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon#cubics()` A flattened version of the `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Feature`s, as a List. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/graphics/shapes/Feature>` | `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon#features()` | Cmn |

| ### Extension functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path` | `@https://developer.android.com/reference/kotlin/androidx/compose/material3/ExperimentalMaterial3ExpressiveApi @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon.https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon#(androidx.graphics.shapes.RoundedPolygon).toPath(kotlin.Int)(startAngle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns a `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path` that is remembered across compositions for this `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Shape` | `@https://developer.android.com/reference/kotlin/androidx/compose/material3/ExperimentalMaterial3ExpressiveApi @https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon.https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon#(androidx.graphics.shapes.RoundedPolygon).toShape(kotlin.Int)(startAngle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns a `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Shape` that is remembered across compositions for this `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon`. | Cmn |
| `https://developer.android.com/reference/android/graphics/Path.html` | `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon.https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon#(androidx.graphics.shapes.RoundedPolygon).toPath(android.graphics.Path)(path: https://developer.android.com/reference/android/graphics/Path.html)` Gets a `https://developer.android.com/reference/android/graphics/Path.html` representation for a `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon` shape. | android |
| `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon` | `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon.https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon#(androidx.graphics.shapes.RoundedPolygon).transformed(android.graphics.Matrix)(matrix: https://developer.android.com/reference/android/graphics/Matrix.html)` Transforms a `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon` by the given matrix. | android |

## Public functions

### calculateBounds

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

```
fun calculateBounds(
    bounds: FloatArray = FloatArray(4),
    approximate: Boolean = true
): FloatArray
```

Calculates the axis-aligned bounds of the object.

| Parameters |
|---|---|
| `bounds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html = FloatArray(4)` | a buffer to hold the results. If not supplied, a temporary buffer will be created. |
| `approximate: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html = true` | 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://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html` | 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

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

```
fun calculateMaxBounds(bounds: FloatArray = FloatArray(4)): FloatArray
```

Like `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `bounds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html = FloatArray(4)` | a buffer to hold the results. If not supplied, a temporary buffer will be created. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float-array/index.html` | 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

Cmn

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

### hashCode

Cmn

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

### normalized

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

```
fun normalized(): RoundedPolygon
```

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

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): RoundedPolygon
```

Transforms (scales/translates/etc.) this `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon` with the given `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/PointTransformer` and returns a new `https://developer.android.com/reference/kotlin/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/kotlin/androidx/graphics/shapes/RoundedPolygon` provided by the platform specific wrapper.

| Parameters |
|---|---|
| `f: https://developer.android.com/reference/kotlin/androidx/graphics/shapes/PointTransformer` | The `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/PointTransformer` used to transform this `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon` |

## Public properties

### centerX

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

```
val centerX: Float
```

### centerY

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

```
val centerY: Float
```

### cubics

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

```
val cubics: List<Cubic>
```

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

### features

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

```
val features: List<Feature>
```

## Extension functions

### RoundedPolygon.toPath

Cmn Artifact: [androidx.compose.material3:material3](https://developer.android.com/jetpack/androidx/releases/compose-material3) [View Source](https://cs.android.com/search?q=file:androidx/compose/material3/MaterialShapes.kt+function:toPath)

```
@ExperimentalMaterial3ExpressiveApi
@Composable
fun RoundedPolygon.toPath(startAngle: Int = 0): Path
```

Returns a `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path` that is remembered across compositions for this `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon`.

| Parameters |
|---|---|
| `startAngle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | the angle (in degrees) from which to begin drawing the generated path. By default, it is set to 0 degrees, meaning the `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Path` begins drawing at the 3 o'clock position. The returned path is rotated by this angle around the `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon`'s centroid (centerX, centerY). |

### RoundedPolygon.toShape

Cmn Artifact: [androidx.compose.material3:material3](https://developer.android.com/jetpack/androidx/releases/compose-material3) [View Source](https://cs.android.com/search?q=file:androidx/compose/material3/MaterialShapes.kt+function:toShape)

```
@ExperimentalMaterial3ExpressiveApi
@Composable
fun RoundedPolygon.toShape(startAngle: Int = 0): Shape
```

Returns a `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Shape` that is remembered across compositions for this `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon`.

| Parameters |
|---|---|
| `startAngle: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html = 0` | the angle (in degrees) from which to begin drawing the generated shape's path. By default, it is set to 0 degrees, meaning the shape's path begins drawing at the 3 o'clock position. The returned path is rotated by this angle around the `https://developer.android.com/reference/kotlin/androidx/graphics/shapes/RoundedPolygon`'s centroid (centerX, centerY). |

### RoundedPolygon.toPath

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

```
fun RoundedPolygon.toPath(path: Path = Path()): Path
```

Gets a `https://developer.android.com/reference/android/graphics/Path.html` representation for a `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `path: 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 |

### RoundedPolygon.transformed

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

```
fun RoundedPolygon.transformed(matrix: Matrix): RoundedPolygon
```

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

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