Game-Collisions
view release on metacpan or search on metacpan
nytprof/js/jit/jit.js view on Meta::CPAN
},
/*
Method: disposeLabel
Removes a label.
Parameters:
id - A label id (which generally is also a <Graph.Node> id).
Example:
(start code js)
var rg = new RGraph(canvas, config); //can be also Hypertree or ST
rg.fx.disposeLabel('labelid');
(end code)
*/
disposeLabel: function(id) {
var elem = this.getLabel(id);
if(elem && elem.parentNode) {
elem.parentNode.removeChild(elem);
}
},
/*
Method: hideLabel
Hides the corresponding <Graph.Node> label.
Parameters:
node - A <Graph.Node>. Can also be an array of <Graph.Nodes>.
flag - If *true*, nodes will be shown. Otherwise nodes will be hidden.
Example:
(start code js)
var rg = new RGraph(canvas, config); //can be also Hypertree or ST
rg.fx.hideLabel(rg.graph.getNode('someid'), false);
(end code)
*/
hideLabel: function(node, flag) {
node = $splat(node);
var st = flag? "" : "none", lab, that = this;
$each(node, function(n) {
var lab = that.getLabel(n.id);
if (lab) {
lab.style.display = st;
}
});
},
/*
Method: sequence
Iteratively performs an action while refreshing the state of the visualization.
Parameters:
options - Some sequence options like
- _condition_ A function returning a boolean instance in order to stop iterations.
- _step_ A function to execute on each step of the iteration.
- _onComplete_ A function to execute when the sequence finishes.
- _duration_ Duration (in milliseconds) of each step.
Example:
(start code js)
var rg = new RGraph(canvas, config); //can be also Hypertree or ST
var i = 0;
rg.fx.sequence({
condition: function() {
return i == 10;
},
step: function() {
alert(i++);
},
onComplete: function() {
alert('done!');
}
});
(end code)
*/
sequence: function(options) {
var that = this;
options = $merge({
condition: $lambda(false),
step: $empty,
onComplete: $empty,
duration: 200
}, options || {});
var interval = setInterval(function() {
if(options.condition()) {
options.step();
} else {
clearInterval(interval);
options.onComplete();
}
that.viz.refresh(true);
}, options.duration);
},
/*
Method: animate
Animates a <Graph> by interpolating some <Graph.Nodes> properties.
Parameters:
opt - Animation options. This object contains as properties
- _modes_ (required) An Array of animation types. Possible values are "linear", "polar", "moebius", "fade:nodes" and "fade:vertex".
"linear", "polar" and "moebius" animation options will interpolate <Graph.Nodes> "startPos" and "endPos" properties, storing the result in "pos".
"fade:nodes" and "fade:vertex" animation options will interpolate <Graph.Nodes> and/or <Graph.Adjacence> "startAlpha" and "endAlpha" properties, storing the result in "alpha".
- _duration_ Duration (in milliseconds) of the Animation.
- _fps_ Frames per second.
- _hideLabels_ hide labels or not during the animation.
( run in 0.996 second using v1.01-cache-2.11-cpan-71847e10f99 )