完成世界书、骰子、apiconfig页面处理
This commit is contained in:
40
frontend/node_modules/d3-force/src/center.js
generated
vendored
Normal file
40
frontend/node_modules/d3-force/src/center.js
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
export default function(x, y) {
|
||||
var nodes, strength = 1;
|
||||
|
||||
if (x == null) x = 0;
|
||||
if (y == null) y = 0;
|
||||
|
||||
function force() {
|
||||
var i,
|
||||
n = nodes.length,
|
||||
node,
|
||||
sx = 0,
|
||||
sy = 0;
|
||||
|
||||
for (i = 0; i < n; ++i) {
|
||||
node = nodes[i], sx += node.x, sy += node.y;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
force.initialize = function(_) {
|
||||
nodes = _;
|
||||
};
|
||||
|
||||
force.x = function(_) {
|
||||
return arguments.length ? (x = +_, force) : x;
|
||||
};
|
||||
|
||||
force.y = function(_) {
|
||||
return arguments.length ? (y = +_, force) : y;
|
||||
};
|
||||
|
||||
force.strength = function(_) {
|
||||
return arguments.length ? (strength = +_, force) : strength;
|
||||
};
|
||||
|
||||
return force;
|
||||
}
|
||||
57
frontend/node_modules/d3-force/src/radial.js
generated
vendored
Normal file
57
frontend/node_modules/d3-force/src/radial.js
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
import constant from "./constant.js";
|
||||
|
||||
export default function(radius, x, y) {
|
||||
var nodes,
|
||||
strength = constant(0.1),
|
||||
strengths,
|
||||
radiuses;
|
||||
|
||||
if (typeof radius !== "function") radius = constant(+radius);
|
||||
if (x == null) x = 0;
|
||||
if (y == null) y = 0;
|
||||
|
||||
function force(alpha) {
|
||||
for (var i = 0, n = nodes.length; i < n; ++i) {
|
||||
var node = nodes[i],
|
||||
dx = node.x - x || 1e-6,
|
||||
dy = node.y - y || 1e-6,
|
||||
r = Math.sqrt(dx * dx + dy * dy),
|
||||
k = (radiuses[i] - r) * strengths[i] * alpha / r;
|
||||
node.vx += dx * k;
|
||||
node.vy += dy * k;
|
||||
}
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
if (!nodes) return;
|
||||
var i, n = nodes.length;
|
||||
strengths = new Array(n);
|
||||
radiuses = new Array(n);
|
||||
for (i = 0; i < n; ++i) {
|
||||
radiuses[i] = +radius(nodes[i], i, nodes);
|
||||
strengths[i] = isNaN(radiuses[i]) ? 0 : +strength(nodes[i], i, nodes);
|
||||
}
|
||||
}
|
||||
|
||||
force.initialize = function(_) {
|
||||
nodes = _, initialize();
|
||||
};
|
||||
|
||||
force.strength = function(_) {
|
||||
return arguments.length ? (strength = typeof _ === "function" ? _ : constant(+_), initialize(), force) : strength;
|
||||
};
|
||||
|
||||
force.radius = function(_) {
|
||||
return arguments.length ? (radius = typeof _ === "function" ? _ : constant(+_), initialize(), force) : radius;
|
||||
};
|
||||
|
||||
force.x = function(_) {
|
||||
return arguments.length ? (x = +_, force) : x;
|
||||
};
|
||||
|
||||
force.y = function(_) {
|
||||
return arguments.length ? (y = +_, force) : y;
|
||||
};
|
||||
|
||||
return force;
|
||||
}
|
||||
Reference in New Issue
Block a user