home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
aminet
/
proclib20.lha
/
Graphics
/
_FAST_LINE.Amos
/
_FAST_LINE.amosSourceCode
Wrap
AMOS Source Code
|
1993-09-30
|
2KB
|
78 lines
Procedure _FAST_LINE[X1,Y1,X2,Y2]
'
'
' Version: 1.0
' By: ** Michael Sikorsky **
' e-mail: sikorsky@bode.ee.ualberta.ca
'
' Distribution: This program is freely distributable. All I ask is if
' you make changes,improvements, or bug fixes (etc) that
' you mail me a new copy of the source. Also somekind
' of acknowledgment in your greetings/credits/manual/etc
' would be appreciated, thanks.
'
' Requirements: none.
'
' Description: Draws a line using only fixed point math (Bressenham)
' (note: can change the Plot command to something like
' Paste Icon...)
'
' Parameters: (X1,Y1) = co-ords of one end point.
' (X2,Y2) = co-ords of the other end point.
'
' Returns: nothing.
'
' Example: _FAST_LINE[10,10,50,50] : Rem Draws a Line from (10,10) to (50,50)
'
DX=X2-X1
DY=Y2-Y1
If(DX<0)
X_INC=-1
Else
X_INC=1
End If
L=Abs(DX)
If(DY<0)
Y_INC=-1
Else
Y_INC=1
End If
M=Abs(DY)
DX2=2*L
DY2=2*M
If(L>=M)
ERR=DY2-L
I=0
While I<L
Plot X1,Y1
If(ERR>0)
Add Y1,Y_INC
Add ERR,-DX2
End If
Add ERR,DY2
Add X1,X_INC
Inc I
Wend
Else
ERR=DX2-M
I=0
While I<M
Plot X1,Y1
If(ERR>0)
Add X1,X_INC
Add ERR,-DY2
End If
Add ERR,DX2
Add Y1,Y_INC
Inc I
Wend
End If
Plot X1,Y1
'
End Proc