Built with blockbuilder.org
forked from anonymous's block: fresh block
| license: mit |
Built with blockbuilder.org
forked from anonymous's block: fresh block
| <!DOCTYPE html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.3/require.min.js"></script> | |
| <style> | |
| body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } | |
| </style> | |
| </head> | |
| <body> | |
| <script> | |
| // Feel free to change or delete any of the code you see in this editor! | |
| require(['https://datawrapper.dwcdn.net/assets/d3/d3v4+jetpack.js'], function(d3) { | |
| console.log(d3); | |
| var svg = d3.select("body").append("svg") | |
| .attr("width", 700 ) | |
| .attr("height", 700) | |
| .append('g').translate([350, 350]); | |
| var spacing = 43, | |
| radius = 1334, | |
| theta = Math.PI * (3 - Math.sqrt(5)), | |
| sites = []; | |
| for (var i = 0.5, r, a, x, y; (r = spacing * Math.sqrt(i)) < radius; ++i) { | |
| x = r * Math.cos(a = i * theta); | |
| //if (-spacing > x || x > width + spacing) continue; | |
| y = r * Math.sin(a); | |
| // if (-spacing > y || y > height + spacing) continue; | |
| sites.push([x, y]); | |
| if (sites.length == 35) break; | |
| } | |
| svg.appendMany(sites, 'circle') | |
| .translate(d3.f()) | |
| .attr('r',5); | |
| }); | |
| // svg.selectAll | |
| </script> | |
| </body> |