1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53:
| procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin if button=mbleft then begin n:=n+1; xp[n]:=x; yp[n]:=y; image1.Canvas.Pen.Color:=clgreen; image1.Canvas.rectangle(x-3,y-3,x+3,y+3); if n>1 then begin image1.Canvas. MoveTo(xp[n-1],yp[n-1]); image1.Canvas.LineTo(xp[n],yp[n]); if ssalt in shift then begin image1.canvas.LineTo(xp[1],yp[1]); end; end; end;
end;
procedure TForm1.Button1Click(Sender: TObject); var i,p: Integer; weitester: Integer; Distanz: Real; begin if n>1 then begin weitester:=0; Distanz:=0; for i:=2 to n do begin if sqrt(sqr(xp[1]-xp[i])+(sqr(yp[1]-yp[i])))>Distanz then begin weitester:=i; p:=i; Distanz:=sqrt(sqr(xp[1]-xp[i])+(sqr(yp[1]-yp[i]))); end; label2.Caption:=inttostr(p); end; image1.Canvas.Pen.Color:=clRed; image1.Canvas.MoveTo(xp[1],yp[1]); image1.Canvas.LineTo(xp[weitester],yp[weitester]); end
end;
end.
Gruß Annika |