1;
    if (outline) {
      ctx.strokeStyle = ctx.fillStyle;
      ctx.stroke();
    }
  }

  function getClosestPoint(points, pos) {
    let ndx = 0;
    let closestDistSq = v2.distanceSq(points[0], pos);
    for (let i = 1; i < points.length; ++i) {
      const distSq = v2.distanceSq(points[i], pos);
      if (distSq < closestDistSq) {
        closestDistSq = distSq;
        ndx = i;
      }
    }
    return ndx;
  }

  function clamp(v, min, max) {
    return Math.max(Math.min(v, max), min);
  }

  funct