Published
Edited
Apr 10, 2021
1 star
Insert cell
Insert cell
viewof SVG = {
now;

const svg = d3.create('svg')
.attr("width", W)
.attr("height", W)
const main = svg.append("g").attr('id','main')

for(let j=0; j<1; j+=.02) {

let x=Math.cos((j+t[0])*TAU)*Math.tan(t[0])*H/10
let y=Math.sin((j-t[0])*TAU)*Math.tan(t[0])*H/10

let circles = main.selectAll("circle")
main.append("circle")

.attr('transform',`translate(${H} ${H}) rotate(.01) `)
.attr('fill','none')
.attr("cx", x)
.attr("cy", y)
.attr("r", 0.5*H*Math.abs(Math.sin(t))*Math.sin(j))
.attr('stroke-opacity',0.5)
.attr('stroke','#000')
.attr('stroke-width',2)
t[0]+=0.000075 // WAS 2e-5
}
return svg.node()
}

Insert cell
t = [0.5] // work around for observable due to mutating and I just was a let var and not a constant.
Insert cell
TAU = Math.PI*2
Insert cell
W = 720
Insert cell
H = W/2
Insert cell
d3 = require('d3')
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more