Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function TPABounds2(TPA: TPointArray): TBox;
- var
- h, i: Integer;
- begin
- h := High(TPA);
- case (h > -1) of
- True:
- begin
- Result.X1 := TPA[0].X;
- Result.Y1 := TPA[0].Y;
- Result.X2 := TPA[0].X;
- Result.Y2 := TPA[0].Y
- if (h > 0) then
- for i := 1 to h do
- begin
- if (Result.X1 > TPA[i].X) then
- Result.X1 := TPA[i].X
- else
- if (Result.X2 < TPA[i].X) then
- Result.X2 := TPA[i].X;
- if (Result.Y1 > TPA[i].Y) then
- Result.Y1 := TPA[i].Y
- else
- if (Result.Y2 < TPA[i].Y) then
- Result.Y2 := TPA[i].Y;
- end;
- end;
- False:
- begin
- Result.X1 := 0;
- Result.Y1 := 0;
- Result.X2 := 0;
- Result.Y2 := 0;
- end;
- end;
- end;
- var
- TPA: TPointArray;
- begin
- TPA := [Point(5, 10), Point(4, 4), Point(8, 12)];
- WriteLn(BoxToStr(TPABounds2(TPA)));
- end.
Advertisement
Add Comment
Please, Sign In to add comment