Snap/Fit a chain of lines to points
Yes.  This is eminently doable.  Here's the general recipe:


Define an "loss function" $L$.  The loss function takes as input the location of the connecting points, and it outputs a measure of how good/bad this set of connecting points is.  Smaller is better.  You mention "minimizing some distance"; this is where you put that, but you'll need to decide on a specific loss function you want to minimize.  If there are four connecting points, the loss function will take the form $L((x_1,y_1),(x_2,y_2),(x_3,y_3),(x_4,y_4))$ and will output a single real number.  Choose a function that is continuous and differentiable.
Use gradient descent to find a location for the connecting points that minimizes the loss function.  Pick some reasonable initialization value (e.g., where the user initially drew the lines; or use some heuristic to pick a crude guess at where to put the connecting points), and then use gradient descent to improve this initial choice and find a minimum for $L$.


This should be very efficient.  It's also very flexible: if you decide you want a different criterion for what the line should look like, you achieve that by modifying the loss function.  There are standard libraries for gradient descent, or if you prefer, you can implement it yourself without too much difficulty.