function draw(orbits, planets) {
const TAU = 2 * Math.PI
const radius = h/8
const center = { x: w/2, y: h/2 }
for (let i = 1; i <= c; i++) {
const r = radius * Math.pow(i, 3)
const l = 1 * Math.pow(i, 2)
const o = i === 1 ? 1 : 0
orbits.append('circle')
.attr('r', r)
.attr('stroke-width', l * 4)
.attr('stroke', '#18435A')
.attr('fill-opacity', 0)
.attr('cx', center.x)
.attr('cy', center.y)
orbits.append('circle')
.attr('r', r)
.attr('stroke-width', l)
.attr('fill-opacity', o)
.attr('cx', center.x)
.attr('cy', center.y)
if (i === 1) continue
const radians = Math.random() * TAU
const max = Math.floor(Math.random() * m)
for(let j = 1; j <= max; j++) {
const cx = Math.sin(radians + TAU / max * j) * r + center.x
const cy = Math.cos(radians + TAU / max * j) * r + center.y
const pr = 30 * l
const avatar = names[Math.floor(Math.random() * names.length)].toLowerCase().replace(' ', '-')
planets.append('circle')
.attr('class', 'planet')
.attr('r', 30 * l)
.attr('cx', cx)
.attr('cy', cy)
.attr('stroke-width', l * 5)
.style('fill', '#16324F')
.style('fill', () => `url(#${avatar})`)
.on('mouseover', function() {
d3.select(this)
.transition(300)
.attr('cursor', 'pointer')
.attr('r', pr * 1.8)
})
.on('mouseout', function() {
d3.select(this)
.transition(300)
.attr('r', pr)
})
}
}
}