{
const duration = 1000;
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height]);
const g = svg.append("g").attr("transform", "translate(300,300)");
const starsJoin = g.selectAll('path')
.data(stars)
.join("path")
.attr('class', 'star')
.attr('fill', 'none')
.attr('stroke', d => d3.interpolateRgbBasis(["red", "yellow", "green", "blue", "purple"])(d/d3.max(stars)))
.attr('d', d => star({length, d}))
.style('opacity', 0)
.transition()
.delay(d => d*duration)
.duration(duration)
.ease(d3.easeLinear)
.style('opacity', 1)
.attrTween("stroke-dasharray", function() {
const length = this.getTotalLength();
return d3.interpolate(`0,${length}`, `${length},${length}`);
})
return svg.node();
}