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
|
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
-
created :boolean
-
Indicates whether this LinkType has been created yet in the server.
Type:
- boolean
-
graph :Psynth.Graph
-
The graph to which this LinkType belongs.
Type:
-
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
-
max :number
-
The maximum value for a Link of this LinkType.
Type:
- number
-
name :string
-
The name of this LinkType. Should be unique to this Graph.
Type:
- string
-
sync :boolean
-
Whether or not the icons for this link type should reflect the color.
Type:
- boolean
-
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
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.
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. Example
lt.name = "Pos"; lt.max = 45; lt.update();