function show(projections, polygons) {
const w = width / polygons.length,
h = w,
height = w * projections.length,
context = DOM.context2d(width, height),
path = d3.geoPath().context(context);
function draw(rotate) {
context.clearRect(0, 0, width, height);
projections.forEach((projection, l) => {
path.projection(projection);
projection
.rotate(rotate)
.fitSize([w * 0.9, h], { type: "Sphere" })
.precision(0.1);
polygons.forEach((p, i) => {
projection.translate([w * i + w / 2, h / 2 + l * h]);
context.beginPath();
path({ type: "Sphere" });
context.lineWidth = 1.5;
context.stroke();
context.beginPath();
path(p);
context.fillStyle = green;
context.fill();
context.lineWidth = .5;
context.stroke();
});
projection.translate([w / 2, h / 2]);
});
}
draw([0, 0]);
return d3
.select(context.canvas)
.call(drag(projections, draw, w, h))
.style("cursor", "grab")
.node();
}