Janilabo

GetLHXYFromTPA()

Jun 26th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.94 KB | None | 0 0
  1. procedure GetLHXYFromTPA(TPA: TPointArray; var LX, LY, HX, HY: Integer);
  2. var
  3.   h, i: Integer;
  4.   mn, mx: TPoint;
  5. begin
  6.   mn := Point(-1, -1);
  7.   mx := Point(-1, -1);
  8.   h := High(TPA);
  9.   if (h > -1) then
  10.   begin
  11.     mn := Point(TPA[0].X, TPA[0].Y);
  12.     mx := Point(TPA[0].X, TPA[0].Y);
  13.     if (h > 0) then
  14.     for i := 1 to h do
  15.     begin
  16.       mn.X := Min(mn.X, TPA[i].X);
  17.       mn.Y := Min(mn.Y, TPA[i].Y);
  18.       mx.X := Max(mx.X, TPA[i].X);
  19.       mx.Y := Max(mx.Y, TPA[i].Y);
  20.     end;
  21.   end;
  22.   LX := mn.X;
  23.   LY := mn.Y;
  24.   HX := mx.X;
  25.   HY := mx.Y;
  26. end;
  27.  
  28. var
  29.   lowestX, lowestY, highestX, highestY: Integer;
  30.   TPA: TPointArray;
  31.  
  32. begin
  33.   ClearDebug;
  34.   TPA := TPAFromCircle(50, 50, 10);
  35.   GetLHXYFromTPA(TPA, lowestX, lowestY, highestX, highestY);
  36.   WriteLn('Lowest X' + IntToStr(lowestX));
  37.   WriteLn('Lowest Y' + IntToStr(lowestY));
  38.   WriteLn('Highest X' + IntToStr(highestX));
  39.   WriteLn('Highest Y' + IntToStr(highestY));
  40. end.
Advertisement
Add Comment
Please, Sign In to add comment