close Warning: Can't synchronize with repository "(default)" (No changeset 184 in the repository). Look in the Trac log for more information.

Changeset 168 for trunk/Packages


Ignore:
Timestamp:
Nov 23, 2017, 10:16:50 AM (7 years ago)
Author:
chronos
Message:
  • Modified: Used TPolygon in TCell.
  • Modified: Moved some generic geometry related functions to UGeometry unit.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/Common/UGeometry.pas

    r167 r168  
    3838    function Create(const Points: TPointArray): TPolygon; overload;
    3939    function Create(const Rect: TRect): TPolygon; overload;
     40    function GetRect: TRect;
    4041    procedure AddPoint(const P: TPoint);
    4142    procedure Clear;
     
    6364function SubAngle(A1, A2: Double): Double;
    6465
     66
    6567implementation
    6668
     
    291293  Result.Points[2] := Point(Rect.Right, Rect.Bottom);
    292294  Result.Points[3] := Point(Rect.Left, Rect.Bottom);
     295end;
     296
     297function TPolygon.GetRect: TRect;
     298var
     299  I: Integer;
     300begin
     301  Result := Rect(High(Integer), High(Integer),
     302    Low(Integer), Low(Integer));
     303  for I := 0 to Length(Points) - 1 do
     304  with Points[I] do begin
     305    if X > Result.Right then
     306      Result.Right := X;
     307    if X < Result.Left then
     308      Result.Left := X;
     309    if Y > Result.Bottom then
     310      Result.Bottom := Y;
     311    if Y < Result.Top then
     312      Result.Top := Y;
     313  end;
    293314end;
    294315
Note: See TracChangeset for help on using the changeset viewer.