Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- procedure GetLHXYFromTPA(TPA: TPointArray; var LX, LY, HX, HY: Integer);
- var
- h, i: Integer;
- mn, mx: TPoint;
- begin
- mn := Point(-1, -1);
- mx := Point(-1, -1);
- h := High(TPA);
- if (h > -1) then
- begin
- mn := Point(TPA[0].X, TPA[0].Y);
- mx := Point(TPA[0].X, TPA[0].Y);
- if (h > 0) then
- for i := 1 to h do
- begin
- mn.X := Min(mn.X, TPA[i].X);
- mn.Y := Min(mn.Y, TPA[i].Y);
- mx.X := Max(mx.X, TPA[i].X);
- mx.Y := Max(mx.Y, TPA[i].Y);
- end;
- end;
- LX := mn.X;
- LY := mn.Y;
- HX := mx.X;
- HY := mx.Y;
- end;
- var
- lowestX, lowestY, highestX, highestY: Integer;
- TPA: TPointArray;
- begin
- ClearDebug;
- TPA := TPAFromCircle(50, 50, 10);
- GetLHXYFromTPA(TPA, lowestX, lowestY, highestX, highestY);
- WriteLn('Lowest X' + IntToStr(lowestX));
- WriteLn('Lowest Y' + IntToStr(lowestY));
- WriteLn('Highest X' + IntToStr(highestX));
- WriteLn('Highest Y' + IntToStr(highestY));
- end.
Advertisement
Add Comment
Please, Sign In to add comment