Class: LinkType

Psynth. LinkType

new LinkType(params)

Creates a LinkType object, which defines parameters for Links. It's easier to do this through Psynth.Graph#addLinkType. A LinkType must be added to a Graph before Links can be created of that type.
Parameters:
Name Type Description
params
Properties
Name Type Argument Default Description
name string <optional>
'Links' The name of this LinkType. Should be unique to this Graph.
icon string <optional>
'img/link_icon.png' A URL for an image to display as an icon for this LinkType. Should be 24x21 pixels, with a transparent background.
tile string <optional>
'img/link_tile.png' A URL for an image to display on the tiling sprite for this LinkType. Should be 100x21 pixels, with a transparent background.
color string <optional>
'dynamic' The color for this LinkType. Should be a string such as "#FFFFFF" 'dynamic' will make the color responsive to user palette changes.
max number <optional>
10 The maximum value any Link of this LinkType can have. Must be >= 1.
sync boolean <optional>
true Whether the icons should reflect the color of the line.
Source:
Examples

Using the constructor directly

var lt = new Psynth.LinkType({name: 'Positive',
                              max: 10,
                              icon: 'img/pos_icon.png',
                              tile: 'img/pos_tile.png',
                              color: '#1aa2d4'});
g.addLinkType(lt);

A better way

var lt = g.addLinkType({name: 'Positive',
                        max: 10,
                        icon: 'img/pos_icon.png',
                        tile: 'img/pos_tile.png',
                        color: '#1aa2d4'});

Members

color :string

The color of this LinkType. Should be a string like "#FFFFFF"
Type:
  • string
Default Value:
  • '#1aa2d4'
Source:

created :boolean

Indicates whether this LinkType has been created yet in the server.
Type:
  • boolean
Default Value:
  • false
Source:

graph :Psynth.Graph

The graph to which this LinkType belongs.
Type:
Source:

icon :string

A URL for an image to display as an icon for this LinkType. Should be 24x21 pixels, with a transparent background.
Type:
  • string
Default Value:
  • 'img/link_icon.png'
Source:

max :number

The maximum value for a Link of this LinkType.
Type:
  • number
Default Value:
  • 10
Source:

name :string

The name of this LinkType. Should be unique to this Graph.
Type:
  • string
Default Value:
  • 'Links'
Source:

sync :boolean

Whether or not the icons for this link type should reflect the color.
Type:
  • boolean
Source:

tile :string

A URL for an image to display on the tiling sprite for this LinkType. Should be 100x21 pixels, with a transparent background.
Type:
  • string
Default Value:
  • 'img/link_tile.png'
Source:

Methods

object() → {simpleLinkType}

Formats the LinkType as a JSON-serializable object which contains all necessary information. This is mostly used internally to prepare queries for the server.
Source:
Returns:
Type
simpleLinkType
Example
var q = lt.object();
q.query = "newreltype";
g.queue(q);

update(callback)

Updates the information for this LinkType on the server. This allows you to make multiple edits to a LinkType while only making 1 server call.
Parameters:
Name Type Argument Description
callback function <optional>
An optional function to handle the server response.
Source:
Example
lt.name = "Pos";
lt.max = 45;
lt.update();