androidx.graphics.shapes

RoundedPolygon

Class · from androidx.graphics:graphics-shapes:1.1.0

No hand-written docs yet.

The RoundedPolygon class allows simple construction of polygonal shapes with optional rounding at the vertices. Polygons can be constructed with either the number of vertices desired or an ordered list of vertices.

class RoundedPolygon

How to get one

Create it

Ready-made values and functions that return it

Used by

Parameters that take a RoundedPolygon.

Properties

centerX

val centerX

centerY

val centerY

cubics

val cubics

A flattened version of the Features, as a List.

features

val features: List<Feature>

Functions

transformed

fun transformed(f: PointTransformer): RoundedPolygon

Transforms (scales/translates/etc.) this RoundedPolygon with the given PointTransformer and returns a new RoundedPolygon. This is a low level API and there should be more platform idiomatic ways to transform a RoundedPolygon provided by the platform specific wrapper.

normalized

fun normalized(): RoundedPolygon

Creates a new RoundedPolygon, moving and resizing this one, so it's completely inside the (0, 0) -> (1, 1) square, centered if there extra space in one direction

calculateMaxBounds

fun calculateMaxBounds(
    bounds: FloatArray = FloatArray(4),
): FloatArray

Like calculateBounds, this function calculates the axis-aligned bounds of the object and returns that rectangle. But this function determines the max dimension of the shape (by calculating the distance from its center to the start and midpoint of each curve) and returns a square which can be used to hold the object in any rotation. This function can be used, for example, to calculate the max size of a UI element meant to hold this shape in any rotation.

calculateBounds

fun calculateBounds(
    bounds: FloatArray = FloatArray(4),
    approximate: Boolean = true,
): FloatArray

Calculates the axis-aligned bounds of the object.

Library docs

The RoundedPolygon class allows simple construction of polygonal shapes with optional rounding at the vertices. Polygons can be constructed with either the number of vertices desired or an ordered list of vertices.