distSq <= selectRadiusSq) ? ndx : -1;
  }

  function onEnd(e) {
    moveNdx = -1;
  }

  function onMove(e) {
    if (moveNdx >= 0) {
      const pos = getRelativeMousePosition(ctx.canvas, e);
      const delta = v2.sub(pos, moveLastPos);
      points[moveNdx] = v2.add(points[moveNdx], delta);
      moveLastPos = pos;

      if ((moveNdx === 2 || moveNdx === 4) && locked) {
        const otherNdx = moveNdx == 2 ? 4 : 2;
        points[otherNdx] = v2.add(points[3], v2.sub(points[3], points[moveNdx]));
     