-
Notifications
You must be signed in to change notification settings - Fork 7
/
SCRAPS
49 lines (39 loc) · 1.16 KB
/
SCRAPS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
FR-layout
/*else if(obj.parent) {
var cc = common.dict_to_array(common.walk(obj));
var area = 1000 * 400;
var k = Math.sqrt(area / cc.length);
var pull = function(x) {
if(x === obj.parent) return true;
if(obj.hub_slots) {
return obj.hub_slots.some(function(el) {
return x === el;
});
}
return false;
};
cc.forEach(function(obj2) {
if(obj2 === obj) return;
var dist = common.screen_distance(obj.screen_position, obj2.screen_position);
var dx = obj2.screen_position.x - obj.screen_position.x;
var dy = obj2.screen_position.y - obj.screen_position.y;
if(dist == 0) {
dist = 100;
dx = common.rand() * 50;
dy = common.rand() * 50;
}
var force = 0;
if(pull(obj2)) {
force += dist * dist / k / 10;
}
force += - k * k / dist / 10000;
obj.screen_position.x += dx / dist * force;
obj.screen_position.y += dy / dist * force;
});
ctx.strokeStyle="black";
ctx.lineWidth = 2;
ctx.beginPath();
ctx.moveTo(obj.parent.screen_position.x, obj.parent.screen_position.y);
ctx.lineTo(obj.screen_position.x, obj.screen_position.y);
ctx.stroke();
}*/