home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
sourcecode
/
graphics
/
bresenham.amos
/
bresenham.amosSourceCode
Wrap
AMOS Source Code
|
1991-07-30
|
2KB
|
131 lines
'===============================================================
'
' NAME: BRESENHAM.AMOS
' TIME: 19:10
' DATE: 10/10/92
' CODE: UNCLE SIME
' NOTE: This is the standard technique used for plotting
' lines between 2 points. To find out more get a
' good book on graphics. Try compiling this as
' it will give you a good idea how fast compiled
' code is in comparison to interpreted code. Left
' mouse button to quit.
'
'
' THOUGHT FOT THE DAY: Anyone who cannot cope with mathematics
' is not fully human. At best he is a
' tolerable subhuman who has learned to
' wear shoes, bathe, and not make messes
' in the house.
'
'===============================================================
'
Close Workbench
Close Editor
Screen Close 0
'
Proc SETUP
Proc MAIN
End
'
Procedure SETUP
'
Screen Open 0,640,200,2,Hires
Flash Off
Curs Off
Hide On
Cls 0
Palette $0,$FFF
Ink 1
Paper 0
End Proc
'
Procedure MAIN
'
' Setup required variables
'
Repeat
Cls 0
Locate 0,0
Input "ENTER X1 ";X1
Until X1>=0 and X1<=640
'
Repeat
Cls 0
Locate 0,0
Input "ENTER Y1 ";Y1
Until Y1>=0 and Y1<=200
'
Repeat
Cls 0
Locate 0,0
Input "ENTER X2 ";X2
Until X2>=0 and X2<=640
'
Repeat
Cls 0
Locate 0,0
Input "ENTER Y2 ";Y2
Until Y2>=0 and Y2<=200
'
Cls 0
'
DX=(X2-X1)
DY=(Y2-Y1)
IX=Abs(DX)
IY=Abs(DY)
'
If DX>DY
_INC=DX
Else
_INC=DY
End If
'
_PLOTX=X1
_PLOTY=Y1
'
X=0 : Y=0 : _PLOT=False
'
' The meat of the algorithm starts here
'
Plot _PLOTX,_PLOTY
'
For LOP=0 To _INC
Add X,IX
Add Y,IY
_PLOT=False
'
If X>_INC
_PLOT=True
X=X-_INC
'
If DX>0
Inc _PLOTX
Else
Dec _PLOTX
End If
'
End If
'
If Y>_INC
_PLOT=True
Y=Y-_INC
'
If DY>0
Inc _PLOTY
Else
Dec _PLOTY
End If
'
End If
'
If _PLOT
Plot _PLOTX,_PLOTY
End If
'
Next LOP
Repeat
'
Until Mouse Key=1
Cls 0
End Proc