SUBROUTINE LINE(x2, y2, x1,y1, p)
C.... the presence of C in the first column indicates a comment.
C.... p is a power of 2, and is used to control the line's density.
C.... SIGN (a,b) returns the sign of b attached to a.
dx = x2 - x1
dy = y2 - y1
mx = MAX(ABS(dx), ABS(dy))
mn = MIN(ABS(dx), ABS(dy))
sx = SIGN(2**p, dx)
sy = SIGN(2**p, dy)
k = INT(mx/p + 0.5)
C.... Note division by p is made by a right shift of p places
m = mx/2
do 10 n = 1, k
Plot(x1, y1)
if(dx >= dy) go to 2
y1 = y1 + sy
go to 7
3 continue
if(m + mm >= mx) go to 4
go to 5
7 continue
if(m + mm >= mx) go to 8
go to 5
8 x1 = x1 + sx
go to 6
2 continue
x1 = x1 + sx
go to 3
4 continue
y1 = y1 + sy
go to 6
5 m = m + mm
go to 10
6 m = m + mm - mx
10 continue
return
end |