Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mamayaya1
GitHub Repository: mamayaya1/game
Path: blob/main/projects/HexGL/libs/Editor_files/Links.js
4627 views
1
var pgli = pgli || {};
2
pgli.diagram = pgli.diagram || {};
3
4
pgli.diagram.Links = gamecore.Base.extend('Links',
5
{ // static
6
bezierOffset: 50
7
},
8
{ // instance
9
diagram: null,
10
11
shape: null,
12
13
init: function(diagram)
14
{
15
var static = pgli.diagram.Links;
16
var self = this;
17
18
this.diagram = diagram;
19
20
this.shape = new Kinetic.Shape({
21
drawFunc: function(ctx){
22
ctx.beginPath();
23
24
for(var i = 0, len = self.diagram.nodes.length; i < len; i++)
25
{
26
var node = self.diagram.nodes[i];
27
28
if(! ("layers" in node.module)) continue;
29
30
for(var j = 0, _len = node.module.layers.length; j < _len; j++)
31
{
32
if(! ("use" in node.module.layers[j])) continue;
33
34
var start = node.getLayerSlot(j);
35
var tNode = self.diagram.getNode(node.module.layers[j].use);
36
if(!tNode) continue;
37
var end = tNode.getSlot();
38
39
ctx.moveTo(start[0], start[1]);
40
ctx.bezierCurveTo(
41
start[0]+static.bezierOffset, start[1],
42
end[0]-static.bezierOffset, end[1],
43
end[0], end[1]);
44
}
45
}
46
47
this.stroke(ctx);
48
},
49
x: 0,
50
y: 0,
51
stroke: "#999",
52
strokeWidth: 3,
53
lineCap: "round"
54
});
55
}
56
});
57