Thanks for the code you wrote!
Although I didn't really use much of what you wrote, it brought me to an idea.
Because the paintbox is 600 by 600, I can simply use this:
If a = 0 then begin;
Paintbox1.Canvas.Line(0,bt,600,bt);
end
Else begin
Paintbox1.Canvas.Line(0,300*at + bt,600,-300*at + bt);
end;
Now it works perfectly.
Thanks a lot!