Skip to content

Instantly share code, notes, and snippets.

@gka
Last active February 24, 2017 01:03
Show Gist options
  • Save gka/76876db1d8a3e02c381f0ea36985ab76 to your computer and use it in GitHub Desktop.
Save gka/76876db1d8a3e02c381f0ea36985ab76 to your computer and use it in GitHub Desktop.
fresh block
license: mit
<!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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment