' 'Filled Polygon and Freehand Shape 'Richard Wheeldon 1996 ' 'Draw a shape with the left mouse button. ' Set Buffer 50 Dim ET_YMAX(199,10),ET_XLOW#(199,10),ET_XINC#(199,10) Dim MET(199) Dim AET(20) Repeat : Until Mouse Key OX=X Screen(X Mouse) OY=Y Screen(Y Mouse) RX=OX : RY=OY Do Repeat MK=Mouse Key If MK=0 Exit 2 End If X=X Screen(X Mouse) Y=Y Screen(Y Mouse) Until X<>OX or Y<>OY 'If MK=2 ' Exit 'Else If MK=1 Draw X,Y To OX,OY If YOY ET_YMAX(OY,MET(OY))=Y ET_XLOW#(OY,MET(OY))=OX ET_XINC#(OY,MET(OY))=(1.0*(X-OX))/(Y-OY) Inc MET(OY) End If OX=X : OY=Y 'End If 'While Mouse Key : Wend Loop ' If YRY ET_YMAX(RY,MET(RY))=Y ET_XLOW#(RY,MET(RY))=RX ET_XINC#(RY,MET(RY))=(1.0*(X-RX))/(Y-RY) Inc MET(RY) End If ' Cls 'Draw Polygon For C1=0 To 199 If MET(C1) For C2=0 To MET(C1)-1 Draw ET_XLOW#(C1,C2),C1 To ET_XLOW#(C1,C2)-ET_XINC#(C1,C2)*(C1-ET_YMAX(C1,C2)),ET_YMAX(C1,C2) Next End If Next 'Wait Key ' 'Stage 1 Y=0 Repeat : Inc Y : Until MET(Y) ' 'Stage2 Dim AET_X#(100) Dim AET_YMAX(100) Dim AET_XINC#(100) ' AETMX=0 Repeat '3.1 If MET(Y)>0 For C1=0 To MET(Y)-1 AET_X#(AETMX)=ET_XLOW#(Y,C1) AET_XINC#(AETMX)=ET_XINC#(Y,C1) AET_YMAX(AETMX)=ET_YMAX(Y,C1) Inc AETMX Next For C2=AETMX-2 To 0 Step -1 FLG=True For C1=0 To C2 If AET_X#(C1)>AET_X#(C1+1) Swap AET_X#(C1),AET_X#(C1+1) Swap AET_XINC#(C1),AET_XINC#(C1+1) Swap AET_YMAX(C1),AET_YMAX(C1+1) FLG=False End If Next Exit If FLG Next End If ' 'Print At(0,0);AETMX If AETMX>0 C1=0 : F=False Repeat If AET_YMAX(C1)>Y If F Draw OX,Y To AET_X#(C1),Y F=False Else F=True OX=AET_X#(C1) End If End If Inc C1 Until C1>AETMX End If '3.2 If AETMX>0 C1=0 Repeat If Y>=AET_YMAX(C1) If AETMX-1>C1 For C2=C1 To AETMX-2 AET_X#(C2)=AET_X#(C2+1) AET_XINC#(C2)=AET_XINC#(C2+1) AET_YMAX(C2)=AET_YMAX(C2+1) Next End If Dec AETMX End If Inc C1 Until C1>AETMX-1 End If For C1=0 To AETMX-1 AET_X#(C1)=AET_X#(C1)+AET_XINC#(C1) Next ' 'If AETMX>0 ' For C1=0 To AETMX-2 Step 2 ' Draw AET_X#(C1),Y To AET_X#(C1+1),Y ' Next 'End If ' Inc Y 'Wait Key Until Y>199