el = {
const el = htl.html`<svg width="${walkerHeight}" height="${walkerHeight}" >
<g transform="translate(${walkerHeight / 2}, ${walkerHeight / 2})">
<g class="joints" />
<g class="bones" />
</g>
</svg>`;
const z = d3
.scaleLinear()
.domain([-50, 50])
.range([walkerHeight / 100, walkerHeight / 60]);
const joints = d3
.select(el)
.select("g.joints")
.selectAll("circle")
.data(
drawStyle === "Both" || drawStyle === "Joints only"
? walker.getMarkers(walkerHeight)
: []
)
.join("circle")
.attr("fill", "black");
const bones = d3
.select(el)
.select("g.bones")
.selectAll("line")
.data(
drawStyle === "Both" || drawStyle === "Bones only"
? walker.getLineMarkers(walkerHeight)
: []
)
.join("line")
.attr("fill", "none")
.attr("stroke", "black")
.attr("stroke-width", 1);
function update() {
joints
.data(walker.getMarkers(walkerHeight))
.attr("cx", ({ x }) => x)
.attr("cy", ({ y }) => y)
.attr("r", (d) => z(d.z));
bones
.data(walker.getLineMarkers(walkerHeight))
.attr("x1", ([{ x }]) => x)
.attr("y1", ([{ y }]) => y)
.attr("x2", ([, { x }]) => x)
.attr("y2", ([, { y }]) => y);
}
update();
return Object.assign(el, { update });
}