I just want to paraphrase what you are saying so that we're on the same page. So basically what you want is when you have the mouse button pressed, and you move the muse towards the fixed point, the line will get shorter and if you move the mouse away from the fixed point the line will get longer. But so long as the mouse button is held down, the angle the line is on will remain the same.
Is that correct?
If so. The first thing I would do is calculate the x/y ratio. eg:
float ratio = (mouse_x - initial_x) / (mouse_y - initial_y);
and store either the x or y component at this time:
float x_length = mouse_x - initial_x;
Then I would calculate the length (actually, I'd calculate its square to save calculation on times) of the line as it stands right now:
float initial_line_length = (mouse_x - initial_x) * (mouse_x - initial_x) + (mouse_y - initial_y) * (mouse_y - initial_y);
Then do your loop that checks if the mouse is held down, and while it is, keep rechecking the new squared distance from the current position to the initial position:
<code>float current_line_length = (mouse_x - initial_x) * (mouse_x - initial_x) + (mouse_y - initial_y) * (mouse_y - initial_y);
The new x position for the end of the line is now:
float new_x = initial_x + x_length * initial_line_length / current_line_length;
The new y position is now:
float new_y = initial_y + x_length * initial_line_length / current_line_length * ratio;
If that causes the line to shrink and grow too quickly, just multiply the current_line_length value to some number between 0 and 1 until the speed is good for you.