ExpressiveRoundedPolygon class

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.

Annotations

Constructors

ExpressiveRoundedPolygon.circle({int numVertices = 8, double radius = 1, double centerX = 0, double centerY = 0})
Creates a circular shape, approximating the rounding of the shape around the underlying polygon vertices.
factory
ExpressiveRoundedPolygon.from(ExpressiveRoundedPolygon roundedPolygon)
Creates a copy of the given ExpressiveRoundedPolygon.
ExpressiveRoundedPolygon.fromFeatures(List<ExpressiveFeature> features, {double centerX = double.nan, double centerY = double.nan})
Takes a list of ExpressiveFeature objects that define the polygon's shape and curves. By specifying the features directly, the summarization of ExpressiveShapeCubic objects to curves can be precisely controlled. This affects ExpressivePolygonMorph's default mapping, as curves with the same type (convex or concave) are mapped with each other. For example, if you have a convex curve in your start polygon, ExpressivePolygonMorph will map it to another convex curve in the end polygon.
factory
ExpressiveRoundedPolygon.fromVertices(List<double> vertices, {ExpressiveCornerRounding rounding = ExpressiveCornerRounding.unrounded, List<ExpressiveCornerRounding>? perVertexRounding, double centerX = double.minPositive, double centerY = double.minPositive})
This function takes the vertices (either supplied or calculated, depending on the constructor called), plus ExpressiveCornerRounding parameters, and creates the actual ExpressiveRoundedPolygon shape, rounding around the vertices (or not) as specified. The result is a list of ExpressiveShapeCubic curves which represent the geometry of the final shape.
factory
ExpressiveRoundedPolygon.fromVerticesNum(int numVertices, {double radius = 1, double centerX = 0, double centerY = 0, ExpressiveCornerRounding rounding = ExpressiveCornerRounding.unrounded, List<ExpressiveCornerRounding>? perVertexRounding})
This constructor takes the number of vertices in the resulting polygon. These vertices are positioned on a virtual circle around a given center with each vertex positioned radius distance from that center, equally spaced (with equal angles between them). If no radius is supplied, the shape will be created with a default radius of 1, resulting in a shape whose vertices lie on a unit circle, with width/height of 2. That default polygon will probably need to be rescaled using transformed into the appropriate size for the UI in which it will be drawn.
factory
ExpressiveRoundedPolygon.pill({double width = 2, double height = 1, double smoothing = 0, double centerX = 0, double centerY = 0})
A pill shape consists of a rectangle shape bounded by two semicircles at either of the long ends of the rectangle.
factory
ExpressiveRoundedPolygon.pillStar({double width = 2, double height = 1, int numVerticesPerRadius = 8, double innerRadiusRatio = 0.5, ExpressiveCornerRounding rounding = ExpressiveCornerRounding.unrounded, ExpressiveCornerRounding? innerRounding, List<ExpressiveCornerRounding>? perVertexRounding, double vertexSpacing = 0.5, double startLocation = 0, double centerX = 0, double centerY = 0})
A pillStar shape is like a ExpressiveRoundedPolygon.pill except it has inner and outer radii along its pill-shaped outline, just like a ExpressiveRoundedPolygon.star has inner and outer radii along its circular outline. The parameters for a ExpressiveRoundedPolygon.pillStar are similar to those of a ExpressiveRoundedPolygon.star except, like ExpressiveRoundedPolygon.pill, it has a width and height to determine the general shape of the underlying pill. Also, there is a subtle complication with the way that inner and outer vertices proceed along the circular ends of the shape, depending on the magnitudes of the rounding, innerRounding, and innerRadiusRatio parameters. For example, a shape with outer vertices that lie along the curved end outline will necessarily have inner vertices that are closer to each other, because of the curvature of that part of the shape. Conversely, if the inner vertices are lined up along the pill outline at the ends, then the outer vertices will be much further apart from each other.
factory
ExpressiveRoundedPolygon.rectangle({double width = 2, double height = 2, ExpressiveCornerRounding rounding = ExpressiveCornerRounding.unrounded, List<ExpressiveCornerRounding>? perVertexRounding, double centerX = 0, double centerY = 0})
Creates a rectangular shape with the given width/height around the given center. Optional rounding parameters can be used to create a rounded rectangle instead.
factory
ExpressiveRoundedPolygon.star({required int numVerticesPerRadius, double radius = 1, double innerRadius = 0.5, ExpressiveCornerRounding rounding = ExpressiveCornerRounding.unrounded, ExpressiveCornerRounding? innerRounding, List<ExpressiveCornerRounding>? perVertexRounding, double centerX = 0, double centerY = 0})
Creates a star polygon, which is like a regular polygon except every other vertex is on either an inner or outer radius. The two radii specified in the constructor must both both nonzero. If the radii are equal, the result will be a regular (not star) polygon with twice the number of vertices specified in numVerticesPerRadius.
factory

Properties

center → ExpressivePoint
The polygon's centre.
final
centerX → double
The x coordinate of the centre.
no setter
centerY → double
The y coordinate of the centre.
no setter
cubics → List<ExpressiveShapeCubic>
A flattened version of the ExpressiveFeatures, as a List<ShapeCubic>.
final
features → List<ExpressiveFeature>
The polygon's features, in order around its outline.
final
hashCode → int
The hash code for this object.
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

calculateBounds({List<double>? bounds, bool approximate = true}) → List<double>
Calculates the axis-aligned bounds of the object.
calculateMaxBounds([List<double>? bounds]) → List<double>
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.
normalized() → ExpressiveRoundedPolygon
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.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override
transformed(ExpressivePointTransformer f) → ExpressiveRoundedPolygon
Transforms (scales/translates/etc.) this ExpressiveRoundedPolygon with the given ExpressivePointTransformer and returns a new ExpressiveRoundedPolygon. This is a low level API and there should be more platform idiomatic ways to transform a ExpressiveRoundedPolygon provided by the platform specific wrapper.

Operators

operator ==(Object other) → bool
The equality operator.
override