Class: star

star

Shortcut for creating SVG-based stars

new star(options){star}

Initializes a new star instance.
Name Type Description
options Object Options used to customize the star
Name Type Default Description
parent * optional SVGElement which to append the star's polygon element
id String optional The id of the instance. Auto-generated when not provided
x Number 0 optional Origin of the star along the x-axis
y Number 0 optional Origin of the star along the y-axis
r1 Number 25 optional First radius of the star
r2 Number 50 optional Second radius of the star
points int 5 optional The number of points on the star
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 star's polygon element.
css Object optional CSS Properties to apply to the star's polygon element.
Returns:
Type Description
star A new star 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 star's fill color

readonlyidString

The id of this instance's polygon element

readonlyparentSVGElement

The parent of the polygon element

pointsint

The number of points on the polygon

r1Number

First radius of the star

r2Number

Second radius of the star

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 star's stroke color

strokeWidthNumber

The star's stroke width

xNumber

The origin of the polygon along the x-axis

yNumber

The origin of the polygon along the y-axis

Methods

staticstar.getElInstance(el){star}

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

staticstar.getInstance(id){star}

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

getPoint(index){Array}

Returns the coordinates 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 coordinates at the specified index
Updates the points attribute of the polygon element.