ExpressivePolygonMorph class
This class is used to animate between start and end polygons objects.
Morphing between arbitrary objects can be problematic because it can be
difficult to determine how the points of a given shape map to the points of
some other shape. ExpressivePolygonMorph simplifies the problem by only operating on
ExpressiveRoundedPolygon objects, which are known to have similar, contiguous
structures. For one thing, the shape of a polygon is contiguous from start
to end (compared to an arbitrary Path object, which could have one or more
moveTo operations in the shape). Also, all edges of a polygon shape are
represented by ExpressiveShapeCubic objects, thus the start and end shapes use similar
operations. Two Polygon shapes then only differ in the quantity and
placement of their curves. The morph works by determining how to map the
curves of the two shapes together (based on proximity and other
information, such as distance to polygon vertices and concavity), and
splitting curves when the shapes do not have the same number of curves or
when the curve placement within the shapes is very different.
Constructors
- ExpressivePolygonMorph(ExpressiveRoundedPolygon start, ExpressiveRoundedPolygon end)
-
A morph from
starttoend.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
morphMatch
→ List<
(ExpressiveShapeCubic, ExpressiveShapeCubic)> -
The matched pairs of cubics, start shape first (Compose's public
Morph.morphMatch).no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
asCubics(
double progress) → List< ExpressiveShapeCubic> -
Returns a representation of the morph object at a given
progressvalue as a list of ExpressiveShapeCubics. Note that this function causes a new list to be created and populated, so there is some overhead. -
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.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
writePath(
Path path, double progress, {double scaleX = 1, double scaleY = 1, double dx = 0, double dy = 0}) → void -
Writes the shape at
progressintopath, reset first: the same curves as asCubics (the last one closing exactly on the first anchor), each point scaled by (scaleX,scaleY) then offset by (dx,dy). Allocates nothing: it reads the matched cubics' own arrays and writes straight into the caller's reusedpath, so a morph animates without garbage per frame (Expressive's addition).
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited