I was going through some old code to get some practice and I'm pleased to say I've greatly improved an old line function I wrote some time back. It now draws with far greater precision, no more odd lengths at certain angles and the code is even simpler and tidier. This function draws smoother and more accurate lines than the default line command, but I haven't tested its speed. This could easily be augmented to draw lines on memblock bitmaps so this would be a useful tool for any serious paint program.

set display mode 1360,768,32
hide mouse
sync on
sync rate 0
i = screen width()/4 : u = screen width()-i
j = screen height()/2
ink -2,0
center text i,50, "OBese87's Line Function"
center text u,50, "Dark Basic's Line Command"
for a = 0 to 359
x = sin(a)*250
y = cos(a)*250
oline(i,j,i+x,j+y)
line u,j,u+x,j+y
next a
sync
wait key
end
`Obese87's Line Function
FUNCTION oline(l,t,r,b)
w# = r-l : h# = b-t
rem Store gradient unless line is vertical (undefined gradient h/0), in which case draw with a box and exit.
if w#!0
grad# = h# / w#
else
box l,t,l,b : box l,b,l,t : rem I chose to draw both ways instead of sorting t and b (boxes cannot be drawn upwards in DBC).
exitfunction
endif
rem For shallow gradients we move predominantly along the x axis and vice versa.
if abs(grad#) < 1.0
s = (r>l)-(l>r)
for x = 0 to w# step s
dot l+x, t+round(x*grad#)
next x
else
s = (b>t)-(t>b)
for y = 0 to h# step s
dot l+round(y/grad#), t+y
next y
endif
ENDFUNCTION
`//
function round(n#)
endfunction int(n#+n#) - int(n#)

Shh... you're pretty.