# RoundedPolygonKt

Added in 1.0.0

*** ** * ** ***


```
public final class RoundedPolygonKt
```

<br />

*** ** * ** ***

## Summary

| ### Public methods |
|---|---|
| `static 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/RoundedPolygonKt#RoundedPolygon(androidx.graphics.shapes.RoundedPolygon)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/RoundedPolygon source)` Creates a copy of the given `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(androidx.graphics.shapes.RoundedPolygon)` |
| `static 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/RoundedPolygonKt#RoundedPolygon(kotlin.collections.List,kotlin.Float,kotlin.Float)( @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> features, float centerX, float centerY )` This constructor takes a list of `https://developer.android.com/reference/androidx/graphics/shapes/Feature` objects that define the polygon's shape and curves. |
| `static 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/RoundedPolygonKt#RoundedPolygon(kotlin.FloatArray,androidx.graphics.shapes.CornerRounding,kotlin.collections.List,kotlin.Float,kotlin.Float)( @https://developer.android.com/reference/androidx/annotation/NonNull float[] vertices, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/CornerRounding rounding, 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/CornerRounding> perVertexRounding, float centerX, float centerY )` This function takes the vertices (either supplied or calculated, depending on the constructor called), plus `https://developer.android.com/reference/androidx/graphics/shapes/CornerRounding` parameters, and creates the actual `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(kotlin.FloatArray,androidx.graphics.shapes.CornerRounding,kotlin.collections.List,kotlin.Float,kotlin.Float)` shape, rounding around the vertices (or not) as specified. |
| `static 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/RoundedPolygonKt#RoundedPolygon(kotlin.Int,kotlin.Float,kotlin.Float,kotlin.Float,androidx.graphics.shapes.CornerRounding,kotlin.collections.List)( @https://developer.android.com/reference/androidx/annotation/IntRange(from = 3) int numVertices, float radius, float centerX, float centerY, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/CornerRounding rounding, 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/CornerRounding> perVertexRounding )` This constructor takes the number of vertices in the resulting polygon. |

## Public methods

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

```
public static final @NonNull RoundedPolygon RoundedPolygon(@NonNull RoundedPolygon source)
```

Creates a copy of the given `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(androidx.graphics.shapes.RoundedPolygon)`

### 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+function:RoundedPolygon)

```
public static final @NonNull RoundedPolygon RoundedPolygon(
    @NonNull List<@NonNull Feature> features,
    float centerX,
    float centerY
)
```

This constructor takes a list of `https://developer.android.com/reference/androidx/graphics/shapes/Feature` objects that define the polygon's shape and curves. By specifying the features directly, the summarization of `https://developer.android.com/reference/androidx/graphics/shapes/Cubic` objects to curves can be precisely controlled. This affects `https://developer.android.com/reference/androidx/graphics/shapes/Morph`'s default mapping, as curves with the same type (convex or concave) are mapped with each other. For example, if you have a convex curve in your start polygon, `https://developer.android.com/reference/androidx/graphics/shapes/Morph` will map it to another convex curve in the end polygon.

The `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(kotlin.collections.List,kotlin.Float,kotlin.Float)` and `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(kotlin.collections.List,kotlin.Float,kotlin.Float)` parameters are optional. If not supplied, they will be estimated by calculating the average of all cubic anchor points.

| Parameters |
|---|---|
| `@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> features` | The `https://developer.android.com/reference/androidx/graphics/shapes/Feature`s that describe the characteristics of each outline segment of the polygon. |
| `float centerX` | The X coordinate of the center of the polygon, around which all vertices will be placed. If none provided, the center will be averaged. |
| `float centerY` | The Y coordinate of the center of the polygon, around which all vertices will be placed. If none provided, the center will be averaged. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(kotlin.collections.List,kotlin.Float,kotlin.Float)` must be at least specify 2 features and describe a closed shape. |

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

```
public static final @NonNull RoundedPolygon RoundedPolygon(
    @NonNull float[] vertices,
    @NonNull CornerRounding rounding,
    List<@NonNull CornerRounding> perVertexRounding,
    float centerX,
    float centerY
)
```

This function takes the vertices (either supplied or calculated, depending on the constructor called), plus `https://developer.android.com/reference/androidx/graphics/shapes/CornerRounding` parameters, and creates the actual `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(kotlin.FloatArray,androidx.graphics.shapes.CornerRounding,kotlin.collections.List,kotlin.Float,kotlin.Float)` shape, rounding around the vertices (or not) as specified. The result is a list of `https://developer.android.com/reference/androidx/graphics/shapes/Cubic` curves which represent the geometry of the final shape.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull float[] vertices` | The list of vertices in this polygon specified as pairs of x/y coordinates in this FloatArray. This should be an ordered list (with the outline of the shape going from each vertex to the next in order of this list), otherwise the results will be undefined. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/CornerRounding rounding` | The `https://developer.android.com/reference/androidx/graphics/shapes/CornerRounding` properties of all vertices. If some vertices should have different rounding properties, then use `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(kotlin.FloatArray,androidx.graphics.shapes.CornerRounding,kotlin.collections.List,kotlin.Float,kotlin.Float)` instead. The default rounding value is `https://developer.android.com/reference/androidx/graphics/shapes/CornerRounding#Unrounded()`, meaning that the polygon will use the vertices themselves in the final shape and not curves rounded around the vertices. |
| `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/CornerRounding> perVertexRounding` | The `https://developer.android.com/reference/androidx/graphics/shapes/CornerRounding` properties of all vertices. If this parameter is not null, then it must have the same size as `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(kotlin.FloatArray,androidx.graphics.shapes.CornerRounding,kotlin.collections.List,kotlin.Float,kotlin.Float)`. If this parameter is null, then the polygon will use the `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(kotlin.FloatArray,androidx.graphics.shapes.CornerRounding,kotlin.collections.List,kotlin.Float,kotlin.Float)` parameter for every vertex instead. The default value is null. |
| `float centerX` | The X coordinate of the center of the polygon, around which all vertices will be placed. The default center is at (0,0). |
| `float centerY` | The Y coordinate of the center of the polygon, around which all vertices will be placed. The default center is at (0,0). |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the number of vertices is less than 3 (the `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(kotlin.FloatArray,androidx.graphics.shapes.CornerRounding,kotlin.collections.List,kotlin.Float,kotlin.Float)` parameter has less than 6 Floats). Or if the `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(kotlin.FloatArray,androidx.graphics.shapes.CornerRounding,kotlin.collections.List,kotlin.Float,kotlin.Float)` parameter is not null and the size doesn't match the number vertices. |

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

```
public static final @NonNull RoundedPolygon RoundedPolygon(
    @IntRange(from = 3) int numVertices,
    float radius,
    float centerX,
    float centerY,
    @NonNull CornerRounding rounding,
    List<@NonNull CornerRounding> perVertexRounding
)
```

This constructor takes the number of vertices in the resulting polygon. These vertices are positioned on a virtual circle around a given center with each vertex positioned `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(kotlin.Int,kotlin.Float,kotlin.Float,kotlin.Float,androidx.graphics.shapes.CornerRounding,kotlin.collections.List)` distance from that center, equally spaced (with equal angles between them). If no radius is supplied, the shape will be created with a default radius of 1, resulting in a shape whose vertices lie on a unit circle, with width/height of 2. That default polygon will probably need to be rescaled using `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#(androidx.collection.FloatFloatPair).transformed(androidx.graphics.shapes.PointTransformer)` into the appropriate size for the UI in which it will be drawn.

The `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(kotlin.Int,kotlin.Float,kotlin.Float,kotlin.Float,androidx.graphics.shapes.CornerRounding,kotlin.collections.List)` and `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(kotlin.Int,kotlin.Float,kotlin.Float,kotlin.Float,androidx.graphics.shapes.CornerRounding,kotlin.collections.List)` parameters are optional. If not supplied, the result will be a regular polygon with straight edges and unrounded corners.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 3) int numVertices` | The number of vertices in this polygon. |
| `float radius` | The radius of the polygon, in pixels. This radius determines the initial size of the object, but it can be transformed later by using the `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#(androidx.collection.FloatFloatPair).transformed(androidx.graphics.shapes.PointTransformer)` function. |
| `float centerX` | The X coordinate of the center of the polygon, around which all vertices will be placed. The default center is at (0,0). |
| `float centerY` | The Y coordinate of the center of the polygon, around which all vertices will be placed. The default center is at (0,0). |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/graphics/shapes/CornerRounding rounding` | The `https://developer.android.com/reference/androidx/graphics/shapes/CornerRounding` properties of all vertices. If some vertices should have different rounding properties, then use `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(kotlin.Int,kotlin.Float,kotlin.Float,kotlin.Float,androidx.graphics.shapes.CornerRounding,kotlin.collections.List)` instead. The default rounding value is `https://developer.android.com/reference/androidx/graphics/shapes/CornerRounding#Unrounded()`, meaning that the polygon will use the vertices themselves in the final shape and not curves rounded around the vertices. |
| `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/CornerRounding> perVertexRounding` | The `https://developer.android.com/reference/androidx/graphics/shapes/CornerRounding` properties of every vertex. If this parameter is not null, then it must have `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(kotlin.Int,kotlin.Float,kotlin.Float,kotlin.Float,androidx.graphics.shapes.CornerRounding,kotlin.collections.List)` elements. If this parameter is null, then the polygon will use the `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(kotlin.Int,kotlin.Float,kotlin.Float,kotlin.Float,androidx.graphics.shapes.CornerRounding,kotlin.collections.List)` parameter for every vertex instead. The default value is null. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | If `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(kotlin.Int,kotlin.Float,kotlin.Float,kotlin.Float,androidx.graphics.shapes.CornerRounding,kotlin.collections.List)` is not null and its size is not equal to `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(kotlin.Int,kotlin.Float,kotlin.Float,kotlin.Float,androidx.graphics.shapes.CornerRounding,kotlin.collections.List)`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | `https://developer.android.com/reference/androidx/graphics/shapes/package-summary#RoundedPolygon(kotlin.Int,kotlin.Float,kotlin.Float,kotlin.Float,androidx.graphics.shapes.CornerRounding,kotlin.collections.List)` must be at least 3. |