xxxxxxxxxx
<meta charset="utf-8">
<style>
path {
fill: none;
stroke: #000;
stroke-width: .6px;
}
</style>
<body>
<script src="https://d3js.org/d3.v2.min.js?2.9.3"></script>
<script>
var width = 960,
height = 500,
size = 100,
offset = 0;
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var g = svg.selectAll("g")
.data(d3.geom.voronoi(vertices()))
.enter().append("g");
var path = g.append("path")
.attr("d", function(d) { return "M" + d.join("L") + "Z"; });
var circle = g.append("circle")
.attr("transform", function(d) { return "translate(" + d + ")"; })
.attr("r", 2);
d3.timer(function() {
++offset; if (offset > size) offset -= size;
var data = vertices();
path.data(d3.geom.voronoi(data)).attr("d", function(d) { return "M" + d.join("L") + "Z"; });
circle.data(data).attr("transform", function(d) { return "translate(" + d + ")"; });
});
function vertices() {
return d3.merge(d3.range(-size, width + size, size).map(function(x, i) {
return d3.range(-size, height + size, size).map(function(y, j) {
return [x + (j & 1 ? -offset : offset), y];
});
}));
}
</script>
Modified http://d3js.org/d3.v2.min.js?2.9.3 to a secure url
https://d3js.org/d3.v2.min.js?2.9.3