A2osX/_/MidPoint.bas.txt

61 lines
1.7 KiB
Plaintext
Raw Normal View History

2016-08-28 20:48:01 +00:00
PR#3
NEW
1000 GR
1010 COLOR = 12 : X1% = 3 : Y1% = 0 : X2% = 39 : Y2% = 17
1020 GOSUB 2000
1030 COLOR = 13 : X1% = 2 : Y1% = 1 : X2% = 39 : Y2% = 32
1040 GOSUB 2000
1050 COLOR = 14 : X1% = 1 : Y1% = 2 : X2% = 29 : Y2% = 39
1060 GOSUB 2000
1070 COLOR = 15 : X1% = 0 : Y1% = 3 : X2% = 15 : Y2% = 39
1080 GOSUB 2000
1110 COLOR = 8 : X1% = 36 : Y1% = 0 : X2% = 0 : Y2% = 17
1120 GOSUB 2000
1130 COLOR = 9 : X1% = 37 : Y1% = 1 : X2% = 0 : Y2% = 32
1140 GOSUB 2000
1150 COLOR = 10 : X1% = 38 : Y1% = 2 : X2% = 26 : Y2% = 39
1160 GOSUB 2000
1170 COLOR = 11 : X1% = 39 : Y1% = 3 : X2% = 33 : Y2% = 39
1180 GOSUB 2000
1999 END
2000 VTAB 21 : PRINT "X1=";X1%;" Y1=";Y1%;" X2=";X2%;" Y2=";Y2%
2010 DX% = X2% - X1%
2020 IF DX% = 0 Then VLIN Y1%,Y2% At X1% : RETURN
2030 IF DX% < 0 Then T% = X1% : X1% = X2% : X2% = T% : T% = Y1% : Y1% = Y2% : Y2% = T% : DX% = -DX%
2040 DY% = Y2% - Y1%
2050 IF DY% = 0 Then HLIN X1%,X2% At Y1% : RETURN
2060 IF DY% < 0 Then IY% = -1 : DY% = - DY% : GOTO 2100
2070 IY% = 1
2100 PLOT X1%,Y1%
2110 IF DX% > DY% GOTO 3000
2120 IF DX% < DY% GOTO 4000
2200 IF X1% = X2% THEN RETURN
2210 X1% = X1% + 1
2220 Y1% = Y1% + IY%
2230 PLOT X1%,Y1%
2240 GOTO 2200
3000 IE% = 2 * DY% : D% = IE% - DX% : INE% = 2 * (DY% - DX%)
3010 IF X1% = X2% THEN RETURN
3020 IF D% > 0 THEN D% = D% + INE% : Y1% = Y1% + IY% : GOTO 3040
3030 D% = D% + IE%
3040 X1% = X1% + 1
3050 PLOT X1%,Y1%
3060 GOTO 3010
4000 IE% = 2 * DX% : D% = IE% - DY% : INE% = 2 * (DX% - DY%)
4010 IF Y1% = Y2% THEN RETURN
4020 IF D% > 0 THEN D% = D% + INE% : X1% = X1% + 1 : GOTO 4040
4030 D% = D% + IE%
4040 Y1% = Y1% + IY%
4050 PLOT X1%,Y1%
4060 GOTO 4010