Merge pull request #129 from Fil/phyllotaxis.5

Add .5 to the radius for a nicer density around the origin
This commit is contained in:
Philippe Rivière 2020-05-06 09:52:16 +02:00 committed by GitHub
commit 810f7312ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,7 +64,7 @@ export default function(nodes) {
if (node.fx != null) node.x = node.fx;
if (node.fy != null) node.y = node.fy;
if (isNaN(node.x) || isNaN(node.y)) {
var radius = initialRadius * Math.sqrt(i), angle = i * initialAngle;
var radius = initialRadius * Math.sqrt(0.5 + i), angle = i * initialAngle;
node.x = radius * Math.cos(angle);
node.y = radius * Math.sin(angle);
}