polygon
The polygon
element defines a closed shape consisting of a set of connected straight line segments. The last point is connected to the first point.
For open shapes, see the polyline
element.
Usually, this element is created with:
const polygon = parentElement.add('polygon')
It's possible to create it as a disconnected element with gSVG('polygon')
and attach it to the SVG document with .attachTo()
.
.points()
polygon.points( points )
Set this attribute defines the list of points
(pairs of x,y absolute coordinates) required to draw the polygon.
argument:
{Array<Array<number,number>>|string} points
An array of arrays with[x, y]
values.returns:
{gSVGObject}
The original object
const points = element.points();
Get the points
current value.
- returns:
{Array}
.pathLength()
polygon.pathLength( length )
Set this attribute lets specify the total length for the path, in user units.
argument:
{number} length
The total lengthreturns:
{gSVGObject}
The original object
const pathLength = element.pathLength();
Get the pathLength
current value.