Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
prog:lazarus:classes:trect [20/07/2024 12:19] thierry [TRect] |
prog:lazarus:classes:trect [20/07/2024 12:26] (Version actuelle) thierry [Membres de TRect] |
||
---|---|---|---|
Ligne 12: | Ligne 12: | ||
</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> | ||
+ | |||
+ | |||
+ | |||