# PolygonShapeScope

Artifact: [androidx.compose.foundation:foundation](https://developer.android.com/jetpack/androidx/releases/compose-foundation) [View Source](https://cs.android.com/search?q=file:androidx/compose/foundation/shape/PolygonShape.kt+class:androidx.compose.foundation.shape.PolygonShapeScope) Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.13.0-rc01) Common/All
- Cmn

  ```
  sealed interface PolygonShapeScope : Density
  ```

*** ** * ** ***

Builds `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeGeometry` for a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShape` at layout resolution.

Exposes `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#size()`, `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#layoutDirection()`, and `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density` along with `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.Int,kotlin.Float,androidx.compose.ui.geometry.Offset,androidx.compose.foundation.shape.CornerRounding)` factories. Coordinates are in layout pixels.

```kotlin
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CornerRounding
import androidx.compose.foundation.shape.PolygonShape
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp

// A regular hexagon sized to the container's smaller dimension with an exact 16.dp corner
// rounding resolved against the current density.
val hexagon = remember {
    PolygonShape {
        polygon(
            numVertices = 6,
            radius = size.minDimension / 2f,
            center = Offset(size.width / 2f, size.height / 2f),
            rounding = CornerRounding.dp(radius = 16.dp),
        )
    }
}
Box(Modifier.size(96.dp).clip(hexagon).background(Color(0xFF3F51B5)))
```

```kotlin
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CornerRounding
import androidx.compose.foundation.shape.PolygonShape
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp

// A pointed tag whose arrow tip adapts to the layout size and flips horizontally in RTL.
val tag = remember {
    PolygonShape {
        val isLtr = layoutDirection == LayoutDirection.Ltr
        val tipX = if (isLtr) size.width else 0f
        val baseX = if (isLtr) 0f else size.width
        val indentX = if (isLtr) size.width * 0.2f else size.width * 0.8f
        polygon(
            vertices =
                listOf(
                    Offset(baseX, 0f),
                    Offset(tipX, size.height / 2f),
                    Offset(baseX, size.height),
                    Offset(indentX, size.height / 2f),
                ),
            rounding = CornerRounding.dp(radius = 6.dp),
        )
    }
}
Box(Modifier.size(width = 120.dp, height = 64.dp).clip(tag).background(Color(0xFF4CAF50)))
```

## Summary

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeGeometry` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,androidx.compose.ui.geometry.Offset,androidx.compose.foundation.shape.CornerRounding)(vertices: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset>, center: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, rounding: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding)` Creates polygon geometry from `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,androidx.compose.ui.geometry.Offset,androidx.compose.foundation.shape.CornerRounding)` with uniform `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,androidx.compose.ui.geometry.Offset,androidx.compose.foundation.shape.CornerRounding)`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeGeometry` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,kotlin.collections.List,androidx.compose.ui.geometry.Offset)( vertices: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset>, perVertexRounding: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding>, center: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset )` Creates polygon geometry from `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,kotlin.collections.List,androidx.compose.ui.geometry.Offset)` with per-vertex `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,kotlin.collections.List,androidx.compose.ui.geometry.Offset)`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeGeometry` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.Int,kotlin.collections.List,kotlin.Float,androidx.compose.ui.geometry.Offset)( numVertices: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 3) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, perVertexRounding: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding>, radius: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, fromInclusive = false) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, center: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset )` Creates a regular polygon with `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.Int,kotlin.collections.List,kotlin.Float,androidx.compose.ui.geometry.Offset)` vertices and per-vertex `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.Int,kotlin.collections.List,kotlin.Float,androidx.compose.ui.geometry.Offset)`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeGeometry` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.Int,kotlin.Float,androidx.compose.ui.geometry.Offset,androidx.compose.foundation.shape.CornerRounding)( numVertices: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 3) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, radius: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, fromInclusive = false) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, center: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset, rounding: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding )` Creates a regular polygon with `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.Int,kotlin.Float,androidx.compose.ui.geometry.Offset,androidx.compose.foundation.shape.CornerRounding)` vertices on a circle of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.Int,kotlin.Float,androidx.compose.ui.geometry.Offset,androidx.compose.foundation.shape.CornerRounding)` pixels. | Cmn |

| ### Public properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/LayoutDirection` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#layoutDirection()` Layout direction of the shape. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#size()` Size of the shape's layout container in pixels. | Cmn |

### Inherited functions

From [androidx.compose.ui.unit.Density](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.Dp).roundToPx()()`

Convert `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` to `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` by rounding
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.TextUnit).roundToPx()()`

Convert Sp to `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` by rounding
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(kotlin.Int).toDp()()`

Convert an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` pixel value to `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp`.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(kotlin.Float).toDp()()`

Convert a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` pixel value to a Dp
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpSize` `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.geometry.Size).toDpSize()()`

Convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` to a `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpSize`.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.Dp).toPx()()`

Convert `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` to pixels.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.TextUnit).toPx()()`

Convert Sp to pixels.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpRect.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.DpRect).toRect()()`

Convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpRect` to a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect`.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpSize.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(androidx.compose.ui.unit.DpSize).toSize()()`

Convert a `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/DpSize` to a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Size`.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(kotlin.Int).toSp()()`

Convert an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` pixel value to Sp.
Cmn `open https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#(kotlin.Float).toSp()()`

Convert a `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` pixel value to a Sp
Cmn From [androidx.compose.ui.unit.FontScaling](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling) `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling#(androidx.compose.ui.unit.TextUnit).toDp()()`

Convert Sp to `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp`.
Cmn `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling#(androidx.compose.ui.unit.Dp).toSp()()`

Convert `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` to Sp.
Cmn

### Inherited properties

From [androidx.compose.ui.unit.Density](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density#density()`

The logical density of the display.
Cmn From [androidx.compose.ui.unit.FontScaling](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling#fontScale()`

Current user preference for the scaling factor for fonts.
Cmn

## Public functions

### polygon

Cmn Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.13.0-rc01)

```
fun polygon(
    vertices: List<Offset>,
    center: Offset = Offset.Unspecified,
    rounding: CornerRounding = CornerRounding.Unrounded
): PolygonShapeGeometry
```

Creates polygon geometry from `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,androidx.compose.ui.geometry.Offset,androidx.compose.foundation.shape.CornerRounding)` with uniform `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,androidx.compose.ui.geometry.Offset,androidx.compose.foundation.shape.CornerRounding)`.

Coordinates are in layout pixels (`(0f, 0f)` to `(size.width, size.height)`). You can also define `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,androidx.compose.ui.geometry.Offset,androidx.compose.foundation.shape.CornerRounding)` in a custom coordinate space (such as a `[0f, 1f]` unit square) and scale them to the layout bounds using `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeTransformScope#scaleToFit(androidx.compose.ui.layout.ContentScale,androidx.compose.ui.Alignment)`. Because custom `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,androidx.compose.ui.geometry.Offset,androidx.compose.foundation.shape.CornerRounding)` do not have a circle radius, `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding#fraction(kotlin.Float,kotlin.Float)` sets the corner radius as a fraction of the polygon's smaller dimension (`min(width, height)`).

| Parameters |
|---|---|
| `vertices: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset>` | vertex positions in pixels (or custom coordinates scaled with `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeTransformScope#scaleToFit(androidx.compose.ui.layout.ContentScale,androidx.compose.ui.Alignment)`), at least 3 |
| `center: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset = Offset.Unspecified` | polygon center in pixels, or `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset#Unspecified()` to compute from `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,androidx.compose.ui.geometry.Offset,androidx.compose.foundation.shape.CornerRounding)` |
| `rounding: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding = CornerRounding.Unrounded` | corner rounding applied to every vertex |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,androidx.compose.ui.geometry.Offset,androidx.compose.foundation.shape.CornerRounding)` has fewer than 3 entries |

### polygon

Cmn Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.13.0-rc01)

```
fun polygon(
    vertices: List<Offset>,
    perVertexRounding: List<CornerRounding>,
    center: Offset = Offset.Unspecified
): PolygonShapeGeometry
```

Creates polygon geometry from `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,kotlin.collections.List,androidx.compose.ui.geometry.Offset)` with per-vertex `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,kotlin.collections.List,androidx.compose.ui.geometry.Offset)`.

Coordinates are in layout pixels (`(0f, 0f)` to `(size.width, size.height)`). You can also define `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,kotlin.collections.List,androidx.compose.ui.geometry.Offset)` in a custom coordinate space (such as a `[0f, 1f]` unit square) and scale them to the layout bounds using `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeTransformScope#scaleToFit(androidx.compose.ui.layout.ContentScale,androidx.compose.ui.Alignment)`. Because custom `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,kotlin.collections.List,androidx.compose.ui.geometry.Offset)` do not have a circle radius, `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding#fraction(kotlin.Float,kotlin.Float)` sets the corner radius as a fraction of the polygon's smaller dimension (`min(width, height)`).

| Parameters |
|---|---|
| `vertices: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset>` | vertex positions in pixels (or custom coordinates scaled with `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeTransformScope#scaleToFit(androidx.compose.ui.layout.ContentScale,androidx.compose.ui.Alignment)`), at least 3 |
| `perVertexRounding: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding>` | rounding for each vertex, matching `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,kotlin.collections.List,androidx.compose.ui.geometry.Offset)` in size |
| `center: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset = Offset.Unspecified` | polygon center in pixels, or `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset#Unspecified()` to compute from `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,kotlin.collections.List,androidx.compose.ui.geometry.Offset)` |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,kotlin.collections.List,androidx.compose.ui.geometry.Offset)` has fewer than 3 entries or `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,kotlin.collections.List,androidx.compose.ui.geometry.Offset)` differs from `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.collections.List,kotlin.collections.List,androidx.compose.ui.geometry.Offset)` in size |

### polygon

Cmn Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.13.0-rc01)

```
fun polygon(
    numVertices: @IntRange(from = 3) Int,
    perVertexRounding: List<CornerRounding>,
    radius: @FloatRange(from = 0.0, fromInclusive = false) Float = size.minDimension / 2f,
    center: Offset = size.center
): PolygonShapeGeometry
```

Creates a regular polygon with `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.Int,kotlin.collections.List,kotlin.Float,androidx.compose.ui.geometry.Offset)` vertices and per-vertex `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.Int,kotlin.collections.List,kotlin.Float,androidx.compose.ui.geometry.Offset)`.

`https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.Int,kotlin.collections.List,kotlin.Float,androidx.compose.ui.geometry.Offset)` applies to vertices in clockwise order starting from the right (`0` degrees). `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding#fraction(kotlin.Float,kotlin.Float)` sets the corner radius as a fraction of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.Int,kotlin.collections.List,kotlin.Float,androidx.compose.ui.geometry.Offset)`.

| Parameters |
|---|---|
| `numVertices: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 3) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | number of vertices, at least 3 |
| `perVertexRounding: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding>` | rounding for each vertex, matching `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.Int,kotlin.collections.List,kotlin.Float,androidx.compose.ui.geometry.Offset)` in size |
| `radius: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, fromInclusive = false) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = size.minDimension / 2f` | circle radius in pixels |
| `center: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset = size.center` | polygon center in pixels, defaults to `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/package-summary#(androidx.compose.ui.geometry.Size).center()` |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.Int,kotlin.collections.List,kotlin.Float,androidx.compose.ui.geometry.Offset)` is less than 3 or `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.Int,kotlin.collections.List,kotlin.Float,androidx.compose.ui.geometry.Offset)` differs from `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.Int,kotlin.collections.List,kotlin.Float,androidx.compose.ui.geometry.Offset)` in size |

### polygon

Cmn Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.13.0-rc01)

```
fun polygon(
    numVertices: @IntRange(from = 3) Int,
    radius: @FloatRange(from = 0.0, fromInclusive = false) Float = size.minDimension / 2f,
    center: Offset = size.center,
    rounding: CornerRounding = CornerRounding.Unrounded
): PolygonShapeGeometry
```

Creates a regular polygon with `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.Int,kotlin.Float,androidx.compose.ui.geometry.Offset,androidx.compose.foundation.shape.CornerRounding)` vertices on a circle of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.Int,kotlin.Float,androidx.compose.ui.geometry.Offset,androidx.compose.foundation.shape.CornerRounding)` pixels.

`https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding#fraction(kotlin.Float,kotlin.Float)` sets the corner radius as a fraction of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.Int,kotlin.Float,androidx.compose.ui.geometry.Offset,androidx.compose.foundation.shape.CornerRounding)`.

| Parameters |
|---|---|
| `numVertices: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 3) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | number of vertices, at least 3 |
| `radius: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, fromInclusive = false) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = size.minDimension / 2f` | circle radius in pixels |
| `center: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Offset = size.center` | polygon center in pixels, defaults to `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/package-summary#(androidx.compose.ui.geometry.Size).center()` |
| `rounding: https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding = CornerRounding.Unrounded` | corner rounding applied to every vertex |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope#polygon(kotlin.Int,kotlin.Float,androidx.compose.ui.geometry.Offset,androidx.compose.foundation.shape.CornerRounding)` is less than 3 |

## Public properties

### layoutDirection

Cmn Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.13.0-rc01)

```
val layoutDirection: LayoutDirection
```

Layout direction of the shape.

### size

Cmn

```
val size: Size
```

Size of the shape's layout container in pixels.