JSFiddle - React, Tailwind, and code Playground
by Hamish Wilson
CSS
body {
margin: 0;
background: #222;
min-width: 960px;
}
rect {
fill: none;
pointer-events: all;
}
circle {
fill: none;
stroke-width: 2.5px;
}
JavaScript
var width = Math.max(900, innerWidth),
height = Math.max(700, innerHeight)
var svg = d3.select("body").append("svg")
.attr({
"width": width,
"height": height
})
var i = 1;
svg.append("rect")
.attr({
"width": width,
"height": height
})
.on("mousemove", particle)
function particle() {
var m = d3.mouse(this)
var circle = svg.insert("circle", "rect")
.attr("cx", m[0])
.attr("cy", m[1])
.attr("r", 10)
.style("stroke", d3.hsl((i = (i + 1) % 360), 1, .5))
.style("stroke-opacity", 1)
.transition().duration(1000)
.ease(Math.sqrt)
.attr("r", 100)
.style("stroke-opacity", 1e-6)
}