Record TRectangle
Unit
Declaration
type TRectangle = record
Description
2D rectangle with integer coordinates. Useful for various 2D GUI operations.
The area covered by the rectangle starts in (Left,Bottom) pixel and spans (Width,Height) pixels. This means that the right-top pixel covered by the rectangle is (Left + Width - 1,Bottom + Height - 1). The rectangle is empty (Contains will always answer False
) when either Width or Height are zero. Neither Width nor Height can ever be negative.
Overview
Fields
Left: Integer; |
|
Bottom: Integer; |
|
Width: Cardinal; |
|
Height: Cardinal; |
Methods
class function Empty: TRectangle; static; inline; |
|
function IsEmpty: Boolean; |
|
function Contains(const X, Y: Integer): Boolean; overload; |
|
function Contains(const Point: TVector2): Boolean; overload; |
|
function Contains(const Point: TVector2Integer): Boolean; overload; |
|
function CenterInside(const W, H: Cardinal): TRectangle; |
|
function Grow(const Delta: Integer): TRectangle; overload; |
|
function Grow(const DeltaX, DeltaY: Integer): TRectangle; overload; |
|
function RemoveLeft(W: Cardinal): TRectangle; |
|
function RemoveBottom(H: Cardinal): TRectangle; |
|
function RemoveRight(W: Cardinal): TRectangle; |
|
function RemoveTop(H: Cardinal): TRectangle; |
|
function GrowLeft(const W: Cardinal): TRectangle; |
|
function GrowBottom(const H: Cardinal): TRectangle; |
|
function GrowRight(const W: Cardinal): TRectangle; |
|
function GrowTop(const H: Cardinal): TRectangle; |
|
function LeftPart(W: Cardinal): TRectangle; |
|
function BottomPart(H: Cardinal): TRectangle; |
|
function RightPart(W: Cardinal): TRectangle; |
|
function TopPart(H: Cardinal): TRectangle; |
|
function Middle: TVector2Integer; deprecated 'use Center'; |
|
function Center: TVector2Integer; |
|
function ClampX(const X: Integer): Integer; |
|
function ClampY(const Y: Integer): Integer; |
|
function ScaleToWidth(const NewWidth: Cardinal): TRectangle; |
|
function ScaleToHeight(const NewHeight: Cardinal): TRectangle; |
|
function ScaleAroundCenter(const Factor: Single): TRectangle; |
|
function ScaleAroundMiddle(const Factor: Single): TRectangle; deprecated 'use ScaleAroundCenter'; |
|
function ScaleAround0(const Factor: Single): TRectangle; |
|
function ScaleWidthAround0(const Factor: Single): Cardinal; |
|
function ScaleHeightAround0(const Factor: Single): Cardinal; |
|
function FitInside(const R: TRectangle; const AlignHorizontal: THorizontalPosition = hpMiddle; const AlignVertical: TVerticalPosition = vpMiddle): TRectangle; |
|
function AlignCore( const ThisPosition: THorizontalPosition; const OtherRect: TRectangle; const OtherPosition: THorizontalPosition; const X: Integer = 0): Integer; overload; |
|
function Align( const ThisPosition: THorizontalPosition; const OtherRect: TRectangle; const OtherPosition: THorizontalPosition; const X: Integer = 0): TRectangle; overload; |
|
function AlignCore( const ThisPosition: TVerticalPosition; const OtherRect: TRectangle; const OtherPosition: TVerticalPosition; const Y: Integer = 0): Integer; overload; |
|
function Align( const ThisPosition: TVerticalPosition; const OtherRect: TRectangle; const OtherPosition: TVerticalPosition; const Y: Integer = 0): TRectangle; overload; |
|
function ToString: string; |
|
function Translate(const V: TVector2Integer): TRectangle; |
|
function Collides(const R: TRectangle): Boolean; |
|
class operator + (const R1, R2: TRectangle): TRectangle; |
|
class operator * (const R1, R2: TRectangle): TRectangle; |
|
function Equals(const R: TRectangle): Boolean; |
Properties
property Right: Integer read GetRight; |
|
property Top: Integer read GetTop; |
|
property LeftBottom: TVector2Integer read GetLeftBottom write SetLeftBottom; |
Description
Fields
Left: Integer; |
|
Bottom: Integer; |
|
Width: Cardinal; |
|
Height: Cardinal; |
|
Methods
class function Empty: TRectangle; static; inline; |
|
function IsEmpty: Boolean; |
|
function Contains(const X, Y: Integer): Boolean; overload; |
|
function Contains(const Point: TVector2): Boolean; overload; |
|
function Contains(const Point: TVector2Integer): Boolean; overload; |
|
function CenterInside(const W, H: Cardinal): TRectangle; |
|
Return rectangle with given width and height centered in the middle of this rectangle. The given W, H may be smaller or larger than this rectangle sizes. |
function Grow(const Delta: Integer): TRectangle; overload; |
|
Grow (when Delta > 0) or shrink (when Delta < 0) the rectangle, returning new value. This adds a margin of Delta pixels around all sides of the rectangle, so in total width grows by 2 * Delta, and the same for height. In case of shrinking, we protect from shrinking too much: the resulting width or height is set to zero (which makes a valid and empty rectangle) if shrinking too much. |
function Grow(const DeltaX, DeltaY: Integer): TRectangle; overload; |
|
function RemoveLeft(W: Cardinal): TRectangle; |
|
Returns the rectangle with a number of pixels from given side removed. Returns an empty rectangle if you try to remove too much. |
function RemoveBottom(H: Cardinal): TRectangle; |
|
function RemoveRight(W: Cardinal): TRectangle; |
|
function RemoveTop(H: Cardinal): TRectangle; |
|
function GrowLeft(const W: Cardinal): TRectangle; |
|
Returns the rectangle with a number of pixels on given side added. |
function GrowBottom(const H: Cardinal): TRectangle; |
|
function GrowRight(const W: Cardinal): TRectangle; |
|
function GrowTop(const H: Cardinal): TRectangle; |
|
function LeftPart(W: Cardinal): TRectangle; |
|
Returns the given side of the rectangle, cut down to given number of pixels from given side. This is similar to RemoveXxx methods, but here you specify which side to keep, as opposed to RemoveXxx methods where you specify which side you remove. If the requested size is larger than current size (for example, W > Width for |
function BottomPart(H: Cardinal): TRectangle; |
|
function RightPart(W: Cardinal): TRectangle; |
|
function TopPart(H: Cardinal): TRectangle; |
|
function Middle: TVector2Integer; deprecated 'use Center'; |
|
Warning: this symbol is deprecated: use Center |
function Center: TVector2Integer; |
|
function ClampX(const X: Integer): Integer; |
|
Clamp value to be within allowed horizontal range. That is, clamp to |
function ClampY(const Y: Integer): Integer; |
|
Clamp value to be within allowed vertical range. That is, clamp to |
function ScaleToWidth(const NewWidth: Cardinal): TRectangle; |
|
function ScaleToHeight(const NewHeight: Cardinal): TRectangle; |
|
function ScaleAroundCenter(const Factor: Single): TRectangle; |
|
Scale rectangle position and size around it's own Center point. Since the scaling is independent in each axis, this handles "carefully" a half-empty rectangles (when one size is <= 0, but other is > 0). It scales correctly the positive dimension (not just returns Empty constant), leaving the other dimension (it's position and size) untouched. |
function ScaleAroundMiddle(const Factor: Single): TRectangle; deprecated 'use ScaleAroundCenter'; |
|
Warning: this symbol is deprecated: use ScaleAroundCenter |
function ScaleAround0(const Factor: Single): TRectangle; |
|
Scale rectangle position and size around the (0,0) point. Since the scaling is independent in each axis, this handles "carefully" a half-empty rectangles (when one size is <= 0, but other is > 0). It scales correctly the positive dimension (not just returns Empty constant), leaving the other dimension (it's position and size) untouched. These details matter, e.g. when you set TCastleUserInterface.Width, but not TCastleUserInterface.Height, and then you expect the TCastleUserInterface.EffectiveWidth to work. |
function ScaleWidthAround0(const Factor: Single): Cardinal; |
|
Scale Width, in the same manner as ScaleAround0 would do. |
function ScaleHeightAround0(const Factor: Single): Cardinal; |
|
Scale Height, in the same manner as ScaleAround0 would do. |
function FitInside(const R: TRectangle; const AlignHorizontal: THorizontalPosition = hpMiddle; const AlignVertical: TVerticalPosition = vpMiddle): TRectangle; |
|
Scale and align us to fit inside rectangle R, preserving our aspect ratio. |
function AlignCore( const ThisPosition: THorizontalPosition; const OtherRect: TRectangle; const OtherPosition: THorizontalPosition; const X: Integer = 0): Integer; overload; |
|
Align this rectangle within other rectangle by calculating new value for Left. |
function Align( const ThisPosition: THorizontalPosition; const OtherRect: TRectangle; const OtherPosition: THorizontalPosition; const X: Integer = 0): TRectangle; overload; |
|
function AlignCore( const ThisPosition: TVerticalPosition; const OtherRect: TRectangle; const OtherPosition: TVerticalPosition; const Y: Integer = 0): Integer; overload; |
|
Align this rectangle within other rectangle by calculating new value for Bottom. |
function Align( const ThisPosition: TVerticalPosition; const OtherRect: TRectangle; const OtherPosition: TVerticalPosition; const Y: Integer = 0): TRectangle; overload; |
|
function ToString: string; |
|
function Translate(const V: TVector2Integer): TRectangle; |
|
Move the rectangle. Empty rectangle after moving is still an empty rectangle. |
function Collides(const R: TRectangle): Boolean; |
|
Does it have any common part with another rectangle. |
class operator + (const R1, R2: TRectangle): TRectangle; |
|
Sum of the two rectangles is a bounding rectangle - a smallest rectangle that contains them both. |
class operator * (const R1, R2: TRectangle): TRectangle; |
|
Common part of the two rectangles. |
function Equals(const R: TRectangle): Boolean; |
|
Properties
property Top: Integer read GetTop; |
|
property LeftBottom: TVector2Integer read GetLeftBottom write SetLeftBottom; |
|
Generated by PasDoc 0.16.0.