Class: plyln

plyln

Shortcut for creating SVG polylines

new plyln(options){plyln}

Initializes a new plyln instance.
Name Type Description
options Object Options used to customize the plyln
Name Type Default Description
parent * optional SVGElement which to append the plyln's polyline element
id String optional The id of the instance. Auto-generated when not provided
x Number 0 optional Origin of the polyline along the x-axis
y Number 0 optional Origin of the polyline along the y-axis
points Array optional A 2d array of points used to draw the polyline relative to its origin. Each index in the parent array should contian an arry with two numbers for x and y.
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 plyln's polyline element.
css Object optional CSS Properties to apply to the plyln's polyline element.
Returns:
Type Description
plyln A new plyln instance.

Requires

Members

dasharray*

The stroke-dasharray of the polyline

dashoffset*

The stroke-dashoffset of the polyline

readonlyelSVGElement

The polyline element associated with this instance

fillString

The plyln's fill color

readonlyidString

The id of this instance's polyline element

readonlyparentSVGElement

The parent of the polyline element

pointsArray

An 2d array of points used to draw the polyline relative to its origin

sliceString

Control how much of the polyline'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 plyln's stroke color

strokeWidthNumber

The plyln's stroke width

xNumber

The origin of the polyline along the x-axis

yNumber

The origin of the polyline along the y-axis

Methods

staticplyln.getElInstance(el){plyln}

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

staticplyln.getInstance(id){plyln}

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

addPoint(coords, index){plyln}

Add a new point to the plyln.
Name Type Description
coords Array The new point coordinates
index int optional The insertion index, defaults to the number of points. When negative, becomes the sum of itself and the number points
Returns:
Type Description
plyln The plyln instance

getPoint(index){Array}

Returns the point at the specified index
Name Type Default Description
index int -1 optional The index of the target point. When negative, becomes the sum of itself and the number points
Returns:
Type Description
Array The point at the specified index

removePoint(index){Array}

Remove the point at the specified index
Name Type Default Description
index int -1 optional The index target point. When negative, becomes the sum of itself and the number points
Returns:
Type Description
Array The removed point coordinates

setPoint(coords, index){Array}

Updates the point at the specified index
Name Type Default Description
coords Array The new point coordinates
index int -1 optional The index of the target point. When negative, becomes the sum of itself and the number points
Returns:
Type Description
Array The updated point
Updates the points attribute of the polyline element.