API Docs for: 6.0.1
Show:

Link Class

Extends Base
Module: scrawlPath

Link

Instantiation

  • Objects created via Path factories

Purpose

  • Defines the type of line to be drawn between two Point objects
  • Can be of the form (species): line, bezier, quadratic
  • Posesses actions: 'add', 'move' (to not draw a line), 'close' (end Point is Path object's startPoint), 'end' (for non-closed Path objects)
  • Makes use of additional control points to determine curves

Access

  • scrawl.link.LINKNAME - for the Link object

Constructor

Methods

clone

(
  • items
)
chainable

Clone a Scrawl.js object, optionally altering attribute values in the cloned object

Note that any callback or fn attribute functions will be referenced by the clone, not copied to the clone; these can be overwritten with new anonymous functions by including them in the items argument object

(This function is replaced by the path extension)

Parameters:

  • items Object

    Object containing attribute key:value pairs; will overwrite existing values in the cloned, but not the source, Object

Returns:

Cloned object

Example:

var box = scrawl.makeBlock({
    width: 50,
    height: 50
    });
var newBox = box.clone({
    height: 100
    });
newBox.get('width');        //returns 50
newBox.get('height');       //returns 100

get

(
  • item
)

Retrieve an attribute value. If the attribute value has not been set, then the default value for that attribute will be returned.

Parameters:

  • item String

    Attribute key

Returns:

Attribute value

Example:

var box = scrawl.makeBlock({
    width: 50,
    });
box.get('width');               //returns 50
box.get('height');              //returns 0
box.get('favouriteAnimal');     //returns undefined

getLength

()

Returns length of Link, in pixels

Returns:

Length, in pixels

getPointCoordinates

() private

Position calculation helper function

Result Object contains the following attributes:

  • start - Link.start Point object's local Vector
  • end - Link.end Point object's local Vector
  • control1 - Link.controlPoint1 Point object's local Vector
  • control2 - Link.controlPoint2 Point object's local Vector

Returns:

Result Object

numberConvert

(
  • val
  • dim
)
private

Stamp helper function - convert string percentage values to numerical values

Parameters:

  • val String

    coordinate String

  • dim Number

    dimension value

Returns:

Number - value

parse

()

Turn the object into a JSON String

Returns:

object of object's currently set attributes

pointOnLine

(
  • origin
  • destination
  • val
)
private

Position calculation helper function

Parameters:

  • origin Point

    Start Point for calculation

  • destination Point

    End Point for calculation

  • val Number

    Distance between start and end points, where 0 = start and 1 = end

Returns:

Coordinate Vector

set

(
  • items
)
chainable

Inherited from Base but overwritten in source\scrawlPath.js:1980

Augments Base.set()

Parameters:

  • items Object

    Object consisting of key:value attributes

Returns:

This

setPositions

(
  • [val]
)
chainable

(re)Calculate the Link object's positions array

Parameters:

  • [val] Number optional
    • precision level for the calculation. Default: parent Shape object's precision value

Returns:

This

sketch

(
  • ctx
)
private

Path object drawing helper function

Note: this function is recursive

Parameters:

  • ctx Object

    Entity Cell's <canvas> element's context engine Object

Returns:

True (eventually)

sketchActions

() private

sketch helper object

Properties

comment

String

Comment, for accessibility

Default: ''

controlPoint1

String

POINTNAME of first control Point object - used by quadratic and bezier links

Default: ''

controlPoint2

String

POINTNAME of second control Point object - used by bezier links

Default: ''

endPoint

String

POINTNAME of end Point object - used by line, quadratic and bezier links

Default: ''

entity

String

SPRITENAME of this Link's parent entity object

Default: ''

length

Number private

Link length - this value will be affected by the value of the parent Entity object's precision attribute

Default: 0

name

String

Unique identifier for each object; default: computer-generated String based on Object's type

positionsCumulativeLength

Array private

Positions Arrays along the length of the Link's path - these values will be affected by the value of the parent Entity object's precision attribute

Default: []

positionsLength

Array private

Positions Arrays along the length of the Link's path - these values will be affected by the value of the parent Entity object's precision attribute

Default: []

positionsX

Array private

Positions Arrays along the length of the Link's path - these values will be affected by the value of the parent Entity object's precision attribute

Default: []

positionsY

Array private

Positions Arrays along the length of the Link's path - these values will be affected by the value of the parent Entity object's precision attribute

Default: []

species

String

Type of link - permitted values include: 'line', 'quadratic', 'bezier'

Default: ''

startPoint

String

POINTNAME of start Point object - used by line, quadratic and bezier links

Default: ''

timestamp

String

Creation timestamp

Default: ''

title

String

Title, for accessibility

Default: ''

type

String final

Inherited from Base but overwritten in source\scrawlPath.js:1880

Default: 'Link'