function* exchange(name1, name2) {
const a = rings.filter((d) => d.name === name1)[0],
b = rings.filter((d) => d.name === name2)[0],
{ theta: theta1, radius: radius1 } = a,
{ theta: theta2, radius: radius2 } = b,
thetaScale = d3.scaleLinear().domain([0, 1]).range([theta1, theta2]),
radiusScale = d3.scaleLinear().domain([0, 1]).range([radius1, radius2]),
dom = document.getElementById("div-1");
a.name = name2;
b.name = name1;
var t = 0;
while (t < 1) {
t += 0.01;
a.theta = thetaScale(t);
b.theta = thetaScale(1 - t);
a.radius = radiusScale(t);
b.radius = radiusScale(1 - t);
dom.innerHTML = "";
yield dom.appendChild(redraw());
}
}