MCPcopy
hub / github.com/microsoft/SandDance / force

Function force

docs/app/js/sanddance-app.js:135730–135734  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

135728 if (x == null) x = 0;
135729 if (y == null) y = 0;
135730 function force() {
135731 var i, n = nodes.length, node, sx = 0, sy = 0;
135732 for(i = 0; i < n; ++i)node = nodes[i], sx += node.x, sy += node.y;
135733 for(sx = (sx / n - x) * strength, sy = (sy / n - y) * strength, i = 0; i < n; ++i)node = nodes[i], node.x -= sx, node.y -= sy;
135734 }
135735 force.initialize = function(_) {
135736 nodes = _;
135737 };

Callers 1

tickFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected