# CornerRounding

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.CornerRounding) Added in [1.13.0-rc01](https://developer.android.com/jetpack/androidx/releases/compose-foundation#1.13.0-rc01) Common/All
- Cmn

  ```
  class CornerRounding
  ```

*** ** * ** ***

Defines the radius and smoothness of rounding at a polygon vertex.

- `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding#Unrounded()` (`radius = 0`) keeps a sharp corner.

- `smoothing = 0f` rounds the corner with a circular arc.

- `smoothing > 0f` extends symmetric cubic Bézier flanking curves from the circular arc toward the adjacent edges (`1f` maximizes the flanking curves).

Create instances with `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding#dp(androidx.compose.ui.unit.Dp,kotlin.Float)`, `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding#fraction(kotlin.Float,kotlin.Float)`, or `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding#Unrounded()`.

## Summary

| ### Public companion functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding#dp(androidx.compose.ui.unit.Dp,kotlin.Float)(radius: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp, smoothing: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Creates a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding` with a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding.Companion#dp(androidx.compose.ui.unit.Dp,kotlin.Float)` in `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding#fraction(kotlin.Float,kotlin.Float)( fraction: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, smoothing: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Creates a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding` with a radius as a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding#fraction(kotlin.Float,kotlin.Float)` of the polygon's size. | Cmn |

| ### Public companion properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding#Unrounded()` Sharp corner with a rounding radius of zero. | Cmn |

| ### Public functions |
|---|---|---|
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding#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/compose/foundation/shape/CornerRounding#hashCode()()` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding#toString()()` | Cmn |

## Public companion functions

### dp

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

```
fun dp(radius: Dp, smoothing: @FloatRange(from = 0.0, to = 1.0) Float = 0.0f): CornerRounding
```

Creates a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding` with a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding.Companion#dp(androidx.compose.ui.unit.Dp,kotlin.Float)` in `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp`.

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

| Parameters |
|---|---|
| `radius: https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` | corner rounding radius, at least `0.dp` |
| `smoothing: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = 0.0f` | transition smoothness from the circular arc to adjacent edges, in `0f..1f` |

| 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/CornerRounding.Companion#dp(androidx.compose.ui.unit.Dp,kotlin.Float)` is negative/unspecified or `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding.Companion#dp(androidx.compose.ui.unit.Dp,kotlin.Float)` is outside `0f..1f` |

### fraction

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

```
fun fraction(
    fraction: @FloatRange(from = 0.0, to = 1.0) Float,
    smoothing: @FloatRange(from = 0.0, to = 1.0) Float = 0.0f
): CornerRounding
```

Creates a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding` with a radius as a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding#fraction(kotlin.Float,kotlin.Float)` of the polygon's size.

For polygons defined with a radius (such as `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShape#regularPolygon(kotlin.Int,androidx.compose.foundation.shape.CornerRounding)`, `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShape#star(kotlin.Int,kotlin.Float,androidx.compose.foundation.shape.CornerRounding,androidx.compose.foundation.shape.CornerRounding)`, and `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)` with `radius`), the corner radius is `[fraction] * radius`. For polygons defined with custom `vertices` (`https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeGeometry`), which do not have a radius, the corner radius is a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding#fraction(kotlin.Float,kotlin.Float)` of the polygon's smaller dimension (`min(width, height)`).

```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.graphics.Color
import androidx.compose.ui.unit.dp

// A pentagon whose corners round to a 0.2f fraction of its generating radius, so the rounding
// scales proportionally with the shape at any size.
val pentagon = remember {
    PolygonShape.regularPolygon(numVertices = 5, rounding = CornerRounding.fraction(0.2f))
}
Box(Modifier.size(96.dp).clip(pentagon).background(Color(0xFF009688)))
```

| Parameters |
|---|---|
| `fraction: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | rounding radius as a fraction of the polygon's size, in `0f..1f` |
| `smoothing: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = 0.0f` | transition smoothness from the circular arc to adjacent edges, in `0f..1f` |

| 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/CornerRounding#fraction(kotlin.Float,kotlin.Float)` or `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/CornerRounding.Companion#fraction(kotlin.Float,kotlin.Float)` is outside `0f..1f` |

## Public companion properties

### Unrounded

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

```
val Unrounded: CornerRounding
```

Sharp corner with a rounding radius of zero.

## Public functions

### equals

Cmn

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

### hashCode

Cmn

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

### toString

Cmn

```
open fun toString(): String
```