Overview
ThePolygon class draws a polygon shape from an array of points. It extends the Graphics base class and supports morphing animations between different polygon shapes.
Class Definition
Settings Interface
Properties
An array of polygon corner coordinates.Each
IPoint has the structure:Coordinates as an array of arrays.Each coordinate is
[x, y] format. This is automatically converted to points internally.Number of milliseconds to play morph animation.When the
points property changes, the polygon will animate from the previous shape to the new shape.Easing function to use for animations.Learn more about easing functions
Private Properties
These properties are managed internally:Internal normalized points array used for rendering.
Previous points array used for morphing animations.
Current morph animation progress (0-1).
Minimum X coordinate of all points.
Maximum X coordinate of all points.
Minimum Y coordinate of all points.
Maximum Y coordinate of all points.
Public Properties
The active morph animation instance.This property is set when a morph animation is triggered by changing the
points property.Inherited Properties
AsPolygon extends Graphics, it inherits all graphics properties including:
Stroke (border) color.Learn more about colors, gradients and patterns
Width of the stroke (border) in pixels.
Opacity of the fill. 0 - fully transparent; 1 - fully opaque.
Opacity of the stroke (border). 0 - fully transparent; 1 - fully opaque.
Color of the element’s shadow.Learn more about shadows
Blurriness of the shadow.Learn more about shadows
Example Usage
Basic Polygon
Using Coordinates
Morphing Animation
Notes
- When morphing between polygons with different numbers of points, the class automatically normalizes both shapes to have the same number of points for smooth animation.
- The polygon automatically calculates its bounding box based on the provided points.
- Available since version 5.4.0
See Also
- Polygon documentation
- Rectangle - For rectangular shapes
- Line - For line shapes