At some angles the DB line command is very wobbly (baddum tsh!)
I want to make my own line function but my previous attempt, although accurate, was extremely slow and primitive.
I am pretty sure that the formula used in the DB line function is sound but the reason it looks bad is that DB doesn't round up decimals. I have made a function to round up decimals but I can't work out how to draw an accurate line.
Here is my best attempt, the problem is the formula doesn't work if width or height are 0.
x1=100
y1=100
x2=150
y2=150
ink rgb(0,255,255),0
line x1,y1,x2,y1
line x2,y1,x2,y2
dline(x1+100,y1,x2+100,y1)
dline(x2+100,y1,x2+100,y2)
ink rgb(255,0,0),0
line x1,y1,x2,y2
dLine(x1+100,y1,x2+100,y2)
End
`----------------
` Functions
`----------------
Function dLine(ax,ay,bx,by)
width#=bx-ax : height#=by-ay
x#=ax : y#=ay
Repeat
if height#<>0 then inc x#,round( width#/abs(height#) ) else inc x#,1
if width#<>0 then inc y#,round( height#/abs(width#) ) else inc y#,1
dot x#,y#
Until int(x#)=bx and int(y#)=by
Endfunction
`-----
Function Round(n#)
a=n#+n#
b=n#
n=a-b
Endfunction n