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
RoundedPolygon(numVertices: Int, radius: Float, centerX: Float, centerY: Float, rounding: CornerRounding, perVertexRounding: List<CornerRounding>?)RoundedPolygon(source: RoundedPolygon)RoundedPolygon(vertices: FloatArray, rounding: CornerRounding, perVertexRounding: List<CornerRounding>?, centerX: Float, centerY: Float)RoundedPolygon(features: List<Feature>, centerX: Float, centerY: Float)
Ready-made values and functions that return it
MaterialShapes:Circle,Square,Slanted,Arch,Fan,Arrow,SemiCircle,Oval,Pill,Triangle,Diamond,ClamShell,Pentagon,Gem,Sunny,VerySunny,Cookie4Sided,Cookie6Sided,Cookie7Sided,Cookie9Sided,Cookie12Sided,Ghostish,Clover4Leaf,Clover8Leaf,Burst,SoftBurst,Boom,SoftBoom,Flower,Puffy,PuffyDiamond,PixelCircle,PixelTriangle,Bun,Heart
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.