const len = path.getTotalLength();
    const point = path.getPointAtLength(len * pos);
    c.setAttribute("cx", point.x);
    c.setAttribute("cy", point.y);
  

    const len = node.getTotalLength();
    const nodes = range(100).map(i =>
      node.getPointAtLength(len * i / 100));
  

    const c = p.cloneNode();
    c.setAttribute("d", c.getAttribute("d").split("z")[0] + "z");
  

    function bottomElements(points, tolerance) {
      const max = Math.max(...points.map(p => p.y));
      return points.filter(p => Math.abs(p.y - max) <= tolerance);
    }
  

    function randomElement(array) {
      return array[Math.floor(Math.random() * array.length)];
    }
  

    points.sort((a,b) => a.y - b.y);
    const min = points[0].y;
    const max = last(points).y;
    const pos = min + (max - min) / 2;
    const middle = points.filter(p => abs(p.y - pos) <= tolerance);
  

    const left = randomElement(rightElements(middle));
    nextPoints.filter(p => Math.abs(p.y - left.y) <= tolerance);
  

    const node = document.createElement("path");
    node.setAttribute("d", "m20.4-.771c-.695.185-1.45...");
    node.setAttribute("transform", `translate(${a.x},${a.y})
                                    scale(${distance(a,b) / 20})
                                    rotate(${angle(a, b)})`);
  

https://malteschmitz.github.io/r2r/