# 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 create with:

const polygon = parentElement.add('polygon')

It's possible create as a disconnected element with gySVG('polygon') and attach it to the SVG document with .attachTo().

More info: mdn (opens new window) | w3c (opens new window)

# .points()

polygon.points( _ )

Set this attribute defines the list of points (pairs of x,y absolute coordinates) required to draw the polygon.

  • argument: {} _

  • returns: {gySVGObject} The original object

const points = element.points();

Get the points current value.

  • returns: {}

# .pathLength()

polygon.pathLength( _ )

Set this attribute lets specify the total length for the path, in user units.

  • argument: {} _

  • returns: {gySVGObject} The original object

const pathLength = element.pathLength();

Get the pathLength current value.