setPoint = (elem, pos, x, y, setMid) => {
      // Create a new SVG point
      const pts = elem.points
      const pt = svgroot.createSVGPoint()
      pt.x = x
      pt.y = y

      // If position is "end", set it to the last index
      if (pos === 'end') {
        pos = pts.numberOfItems - 1
      }

      // Try replacing the point at the specified position
      pts.replaceItem(pt, pos)

      // Optionally, set the midpoint
      if (setMid) {
        const ptStart = pts.getItem(0)
        const ptEnd = pts.getItem(pts.numberOfItems - 1)
        setPoint(elem, 1, (ptEnd.x + ptStart.x) / 2, (ptEnd.y + ptStart.y) / 2)
      }
    }
setPoint
@param {Element} elem - The SVG element.
@param {Integer|"end"} pos - The position index or "end".
@param {Float} x - The x-coordinate.
@param {Float} y - The y-coordinate.
@param {boolean} [setMid] - Whether to set the midpoint.
@returns {void}