Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
prog:lazarus:classes:trect [20/07/2024 12:14]
thierry créée
prog:lazarus:classes:trect [20/07/2024 12:26] (Version actuelle)
thierry [Membres de TRect]
Ligne 1: Ligne 1:
 ====== TRect, TPoint etc... ====== ====== TRect, TPoint etc... ======
 ===== TRect ===== ===== TRect =====
 +==== Création ====
 +
 pour créer un TRect :  pour créer un TRect : 
 <code delphi> <code delphi>
 +// Avec les données Left, Top, Right, Bottom ​
 +Rect:​=Classes.Rect(ALeft,​ ATop, ARight, ABottom); //Retourne un TRect (unit Classes)
 +
 +// Avec les données Left, Top, Width, Height ​
 +Rect:​=Bounds(ALeft,​ ATop, AWidth, AHeight); //Retourne un TRect  (unit Classes)
 +
 </​code>​ </​code>​
 +==== Utilitaires ====
 +<code delphi>
 +// Savoir si RectA contient RectB (c'est a dire RectA entoure/​englobe RectB)
 +Bool := RectA.Contains(RectB); ​
 +
 +// Savoir si RectA chevauche ou contient RectB (c'est a dire une partie RectA se trouve sur RectB)
 +Bool := RectA.IntersectsWith(RectB); ​
 +</​code>​
 +==== Membres de TRect ====
 +<code delphi>
 +  TRect =  packed ​ record
 +     ​public
 +       ​constructor Create(Origin:​ TPoint); // empty rect at given origin
 +       ​constructor Create(Origin:​ TPoint; AWidth, AHeight: Longint);
 +       ​constructor Create(ALeft,​ ATop, ARight, ABottom: Longint);
 +       ​constructor Create(P1, P2: TPoint; Normalize: Boolean = False);
 +       ​constructor Create(R: TRect; Normalize: Boolean = False);
 +       class operator = (L, R: TRect): Boolean;
 +       class operator <> (L, R: TRect): Boolean;
 +       class operator + (L, R: TRect): TRect; // union
 +       class operator * (L, R: TRect): TRect; // intersection
 +       class function Empty: TRect; static;
 +       ​procedure NormalizeRect;​
 +       ​function IsEmpty: Boolean;
 +       ​function Contains(Pt:​ TPoint): Boolean;
 +       ​function Contains(R: TRect): Boolean;
 +       ​function IntersectsWith(R:​ TRect): Boolean;
 +       class function Intersect(R1:​ TRect; R2: TRect): TRect; static;
 +       ​procedure Intersect(R:​ TRect);
 +       class function Union(R1, R2: TRect): TRect; static;
 +       ​procedure Union(R: TRect);
 +       class function Union(const Points: array of TPoint): TRect; static;
 +       ​procedure Offset(DX, DY: Longint);
 +       ​procedure Offset(DP: TPoint);
 +       ​procedure SetLocation(X,​ Y: Longint);
 +       ​procedure SetLocation(P:​ TPoint);
 +       ​procedure Inflate(DX, DY: Longint);
 +       ​procedure Inflate(DL, DT, DR, DB: Longint);
 +       ​function CenterPoint:​ TPoint;
 +       ​function SplitRect(SplitType:​ TSplitRectType;​ ASize: Longint): TRect;
 +       ​function SplitRect(SplitType:​ TSplitRectType;​ Percent: Double): TRect;
 +     ​public
 +       ​property Height: Longint read getHeight write setHeight;
 +       ​property Width : Longint read getWidth ​ write setWidth;
 +       ​property Size  : TSize   read getSize ​  write setSize;
 +       ​property Location ​ : TPoint read getLocation write setLocation;​
 +       case Longint of
 +         0: (Left,​Top,​Right,​Bottom : Longint);
 +         1: (TopLeft,​BottomRight : TPoint);
 +         2: (Vector:​TArray4IntegerType);​
 +       end;
 +
 +</​code>​
 +
 +
 +