Here is my implementation of drawing a line dynamically on an SVG surface using the mouse.
First you click down (left or right button) at your starting position.
Then you drag the mouse crosshairs to the final position.
A line is drawn when you release the button.
Some might not like that you don’t see the line as you drag the mouse. I might do a second version that implements that, even though I find it distracting to do it that way.
But right now, this kind fits or is consistent in terms of style as to how you add SVG lines in XVG by clicking on generated “markers.”
Nice and clean, both visually and in terms of the code.