Class: rgplygn

rgplygn

Shortcut for creating SVG-based regular polygons

new rgplygn(options){rgplygn}

Initializes a new rgplygn instance.
Name Type Description
options Object Options used to customize the rgplygn
Name Type Default Description
parent * optional SVGElement which to append the rgplygn's polygon element
id String optional The id of the instance. Auto-generated when not provided
x Number 0 optional Origin of the polygon along the x-axis
y Number 0 optional Origin of the polygon along the y-axis
r Number 30 optional The radius of the polygon
sides int 3 optional The number of sides on the polygon
fill String 'transparent' optional The default fill color
stroke String '#000000' optional The default stroke color
strokeWidth Number 1 optional The default stroke width
attr Object optional Attributes to apply to the rgplygn's polygon element.
css Object optional CSS Properties to apply to the rgplygn's polygon element.
Returns:
Type Description
rgplygn A new rgplygn instance.

Requires

Members

dasharray*

The stroke-dasharray of the polygon

dashoffset*

The stroke-dashoffset of the polygon

readonlyelSVGElement

The polygon element associated with this instance

fillString

The rgplygn's fill color

readonlyidString

The id of this instance's polygon element

readonlyparentSVGElement

The parent of the polygon element

rNumber

The radius of the polygon

sidesint

The number of sides on the polygon

sliceString

Control how much of the polygon's stroke is drawn. Space-delimited values define a slice, ie '10 30'. A single value asserts 0 as the starting value. Accepts percentages for relative values

strokeString

The rgplygn's stroke color

strokeWidthNumber

The rgplygn's stroke width

xNumber

The origin of the polygon along the x-axis

yNumber

The origin of the polygon along the y-axis

Methods

staticrgplygn.getElInstance(el){rgplygn}

returns the rgplygn instance associated with the provided element's id attribute
Name Type Description
el Element The element with the lookup id
Returns:
Type Description
rgplygn The associate rgplygn, if it exists

staticrgplygn.getInstance(id){rgplygn}

returns the rgplygn instance associated with the id
Name Type Description
id String The lookup id
Returns:
Type Description
rgplygn The associate rgplygn, if it exists

getPoint(index){Array}

Returns the point at the specified index
Name Type Default Description
index int -1 optional The index of the desired point. When negative, becomes the sum of itself and the length of the points array
Returns:
Type Description
Array The point at the specified index
Updates the points attribute of the polygon element.