ticked = function () {
svg.selectAll("rect").remove();
svg
.selectAll("rect")
.data(data)
.join("rect")
.attr("width", (d) => d.strength_before / 50)
.attr("height", (d) => d.strength_before / 50)
.attr("x", (d) => d.x - d.strength_before / 50 / 2)
.attr("y", (d) => d.y - d.strength_before / 50 / 2)
.style("fill", (d) => {
let h = (Math.random() - 0.5) * 80;
let s = (Math.random() - 0.7) * 30;
let l = (Math.random() - 0.5) * 30;
return `hsl(${200 + h}, ${40 + s}%, ${60 + l}%)`;
});
}