Class

PolygonShapeGeometry

Geometry describing a polygon's vertices, center, and rounding.

Source set: Common
public class PolygonShapeGeometry internal constructor(
    public val vertices: List<Offset>,
    public val center: Offset,
    public val rounding: CornerRounding,
    @get:Suppress("NullableCollection") public val perVertexRounding: List<CornerRounding>?,
    internal val roundingReference: Size? = null,
)

Geometry describing a polygon's vertices, center, and rounding.

The consumer defines the coordinate space. PolygonShapeScope factories create geometry in pixels in the layout's coordinate space, while geometry passed directly to PolygonShape uses an author-chosen space and is scaled into the layout bounds at resolution time.

Rounding resolves in the vertex coordinate space. A float radius is a length in that space, and a percent radius resolves against the smaller dimension of the vertex bounds.

Functions

equals

Source set: Common
override fun equals(other: Any?): Boolean

hashCode

Source set: Common
override fun hashCode(): Int

toString

Source set: Common
override fun toString(): String

Members

CornerRounding

Source set: Common
public class CornerRounding internal constructor(
        internal val value: Float,
        internal val unit: Int,
        internal val smoothing: Float,
    )

Amount and quality of rounding around a polygon vertex.

A corner takes one of three forms:

  • unrounded, with a radius of 0, keeping the sharp vertex;
  • arc between adjacent edges;

  • rounded with a circular arc, with a smoothing of 0, following an approximated circular
  • flanking curves connect the circular arc to the edges. A smoothing of 0 keeps a purely circular arc and 1 maximizes the flanking curves so they meet in the middle.

  • rounded with continuous curvature, with smoothing > 0, where two symmetric cubic Bézier

Functions

equals

Source set: Common
override fun equals(other: Any?): Boolean

hashCode

Source set: Common
override fun hashCode(): Int

toString

Source set: Common
override fun toString(): String

Members

Companion

Source set: Common
public companion object

Properties

Unrounded

Source set: Common
public val Unrounded: CornerRounding = CornerRounding(0f, UnitLength, 0f)

Rounding with a radius of zero, producing a sharp corner at the vertex.

Companion

Source set: Common
public companion object

Functions

CornerRounding

Source set: Common
public fun CornerRounding(radius: Float, smoothing: Float = 0f): CornerRounding

Creates a CornerRounding with a radius in the same coordinate space as the vertices.

Parameters

radius rounding radius in the vertex coordinate space, at least 0
smoothing the amount by which the arc is "smoothed" by extending the curve from the inner circular arc to the edge between vertices. A value of 0 (no smoothing) indicates that the corner is rounded by only a circular arc; there are no flanking curves. A value of 1 indicates that there is no circular arc in the center; the flanking curves on either side meet at the middle.

Throws: IllegalArgumentException

if radius is negative or smoothing is outside the range 0 to 1

CornerRounding

Source set: Common
public fun CornerRounding(radius: Dp, smoothing: Float = 0f): CornerRounding

Creates a CornerRounding with a radius in Dp, resolved with the shape's density.

Parameters

radius rounding radius of the corner, at least 0
smoothing the amount by which the arc is "smoothed" by extending the curve from the inner circular arc to the edge between vertices. A value of 0 (no smoothing) indicates that the corner is rounded by only a circular arc; there are no flanking curves. A value of 1 indicates that there is no circular arc in the center; the flanking curves on either side meet at the middle.

Throws: IllegalArgumentException

if radius is negative or unspecified, or smoothing is outside the range 0 to 1

CornerRounding

Source set: Common
public fun CornerRounding(
            @IntRange(from = 0, to = 100) percent: Int,
            smoothing: Float = 0f,
        ): CornerRounding

Creates a CornerRounding with a radius as a percent of the geometry it applies to.

The reference is the generating radius for regular polygons and stars, or the smaller dimension of the vertex bounds for vertex-list geometry, so the radius scales with the shape rather than with the layout container.

Parameters

percent rounding radius as a percentage of the geometry, in the range 0 to 100
smoothing the amount by which the arc is "smoothed" by extending the curve from the inner circular arc to the edge between vertices. A value of 0 (no smoothing) indicates that the corner is rounded by only a circular arc; there are no flanking curves. A value of 1 indicates that there is no circular arc in the center; the flanking curves on either side meet at the middle.

Throws: IllegalArgumentException

if percent is outside the range 0 to 100 or smoothing is outside the range 0 to 1

Content updated: