---
title: "PolygonShapeScope"
description: "Receiver scope for the [PolygonShape] builder lambda."
type: "interface"
lastmod: "2026-09-24"
---
## API Reference

> Source set: Common

```kotlin
public sealed interface PolygonShapeScope : Density
```

Receiver scope for the [PolygonShape](/jetpack-compose/androidx.compose.foundation/foundation/functions/PolygonShape/api) builder lambda.

Provides the resolution inputs ([size](/jetpack-compose/androidx.compose.foundation/foundation/functions/size/api), `layoutDirection`, and `Density`) and the factories that
create the [PolygonShapeGeometry](/jetpack-compose/androidx.compose.foundation/foundation/classes/PolygonShapeGeometry/api) the lambda returns. Coordinates are in pixels in the layout's
coordinate space; `Dp` values resolve with the current density, and percent values are
size-proportional.

## Properties

### size

> Source set: Common

```kotlin
public val size: Size
```

Size of the shape's layout container in pixels.

### layoutDirection

> Source set: Common

```kotlin
public val layoutDirection: LayoutDirection
```

Layout direction of the shape.

## Functions

### polygon

> Source set: Common

```kotlin
public fun polygon(
        numVertices: Int,
        radius: Float = size.minDimension / 2f,
        center: Offset = size.center,
        rounding: CornerRounding = CornerRounding.Unrounded,
    ): PolygonShapeGeometry
```

Creates a regular polygon with `numVertices` vertices on a circle of `radius` pixels around
`center`, with the same `rounding` at every vertex.

Rounding resolves against the polygon itself, not the container. A percent radius is a
percentage of `radius`, a `Dp` radius resolves with the current density, and a float radius
is a length in pixels.

#### Parameters

| | |
| --- | --- |
| numVertices | number of vertices, at least 3 |
| radius | radius in pixels of the circle the vertices are placed on |
| center | center of the polygon in pixels, defaults to the container center |
| rounding | rounding applied to every vertex |

#### Throws: IllegalArgumentException

if `numVertices` is less than 3

### polygon

> Source set: Common

```kotlin
public fun polygon(
        numVertices: Int,
        perVertexRounding: List<CornerRounding>,
        radius: Float = size.minDimension / 2f,
        center: Offset = size.center,
    ): PolygonShapeGeometry
```

Creates a regular polygon with `numVertices` vertices on a circle of `radius` pixels around
`center`, with a separate rounding for each vertex.

Rounding resolves against the polygon itself, not the container. A percent radius is a
percentage of `radius`, a `Dp` radius resolves with the current density, and a float radius
is a length in pixels. Vertex i of `perVertexRounding` rounds the vertex at angle
2πi/`numVertices` on the generating circle.

#### Parameters

| | |
| --- | --- |
| numVertices | number of vertices, at least 3 |
| perVertexRounding | rounding for each vertex, matching `numVertices` in size |
| radius | radius in pixels of the circle the vertices are placed on |
| center | center of the polygon in pixels, defaults to the container center |

#### Throws: IllegalArgumentException

if `numVertices` is less than 3, or if `perVertexRounding` differs from `numVertices` in size

### polygon

> Source set: Common

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

Creates polygon geometry from `vertices` in pixels, with the same `rounding` at every vertex.

Rounding resolves against the vertex bounds, not the container. A percent radius is a
percentage of the bounds' smaller dimension, a `Dp` radius resolves with the current density,
and a float radius is a length in pixels.

#### Parameters

| | |
| --- | --- |
| vertices | vertex positions in pixels, at least 3 |
| center | polygon center in pixels, computed from the geometry when unspecified. An explicit center can be specified as a custom transformation or morphing anchor. |
| rounding | rounding applied to every vertex |

#### Throws: IllegalArgumentException

if [vertices](/jetpack-compose/androidx.compose.ui/ui-graphics/classes/Vertices) has fewer than 3 entries

### polygon

> Source set: Common

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

Creates polygon geometry from `vertices` in pixels, with a separate rounding for each vertex.

Rounding resolves against the vertex bounds, not the container. A percent radius is a
percentage of the bounds' smaller dimension, a `Dp` radius resolves with the current density,
and a float radius is a length in pixels.

#### Parameters

| | |
| --- | --- |
| vertices | vertex positions in pixels, at least 3 |
| perVertexRounding | rounding for each vertex, matching [vertices](/jetpack-compose/androidx.compose.ui/ui-graphics/classes/Vertices) in size |
| center | polygon center in pixels, computed from the geometry when unspecified. An explicit center can be specified as a custom transformation or morphing anchor. |

#### Throws: IllegalArgumentException

if [vertices](/jetpack-compose/androidx.compose.ui/ui-graphics/classes/Vertices) has fewer than 3 entries, or if `perVertexRounding` differs from [vertices](/jetpack-compose/androidx.compose.ui/ui-graphics/classes/Vertices) in size

## Code Examples

### PolygonShapeSample

```kotlin
@Sampled
@Composable
fun PolygonShapeSample() {
    // 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(radius = 16.dp),
            )
        }
    }
    Box(Modifier.size(96.dp).clip(hexagon).background(Color(0xFF3F51B5)))
}
```

### DirectionalPolygonShapeSample

```kotlin
@Sampled
@Composable
fun DirectionalPolygonShapeSample() {
    // 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(radius = 6.dp),
            )
        }
    }
    Box(Modifier.size(width = 120.dp, height = 64.dp).clip(tag).background(Color(0xFF4CAF50)))
}
```
