Record TFloatRectangle
Unit
Declaration
type TFloatRectangle = record
Description
2D rectangle with float coordinates. Useful for various 2D GUI operations, and for bounding boxes for 2D objects.
The area covered by the rectangle starts at (Left,Bottom) position and spans (Width,Height) units. The rectangle is empty (Contains will always answer False
) when either Width or Height are less than zero. This is consistent with it's 3D equivalent, TBox3D, and different from it's integer counterpart TRectangle. In case of float bounding box (TBox3D) or float rectangle (TFloatRectangle
), having a zero size makes sense, and it still is something non-empty (a single 2D or 3D point has zero size, but it also still has a position).
Overview
Fields
Left: Single; |
|
Bottom: Single; |
|
Width: Single; |
|
Height: Single; |
Methods
class function Empty: TFloatRectangle; static; inline; |
|
function IsEmpty: Boolean; |
|
function Contains(const X, Y: Single): Boolean; overload; |
|
function Contains(const Point: TVector2): Boolean; overload; |
|
function Contains(const R: TFloatRectangle): Boolean; overload; |
|
function Middle: TVector2; deprecated 'use Center'; |
|
function Center: TVector2; |
|
function CenterInside(const W, H: Single): TFloatRectangle; |
|
function Grow(const Delta: Single): TFloatRectangle; overload; |
|
function Grow(const DeltaX, DeltaY: Single): TFloatRectangle; overload; |
|
function RemoveLeft(W: Single): TFloatRectangle; |
|
function RemoveBottom(H: Single): TFloatRectangle; |
|
function RemoveRight(W: Single): TFloatRectangle; |
|
function RemoveTop(H: Single): TFloatRectangle; |
|
function GrowLeft(const W: Single): TFloatRectangle; |
|
function GrowBottom(const H: Single): TFloatRectangle; |
|
function GrowRight(const W: Single): TFloatRectangle; |
|
function GrowTop(const H: Single): TFloatRectangle; |
|
function LeftPart(W: Single): TFloatRectangle; |
|
function BottomPart(H: Single): TFloatRectangle; |
|
function RightPart(W: Single): TFloatRectangle; |
|
function TopPart(H: Single): TFloatRectangle; |
|
function AlignCore( const ThisPosition: THorizontalPosition; const OtherRect: TFloatRectangle; const OtherPosition: THorizontalPosition; const X: Single = 0): Single; overload; |
|
function Align( const ThisPosition: THorizontalPosition; const OtherRect: TFloatRectangle; const OtherPosition: THorizontalPosition; const X: Single = 0): TFloatRectangle; overload; |
|
function AlignCore( const ThisPosition: TVerticalPosition; const OtherRect: TFloatRectangle; const OtherPosition: TVerticalPosition; const Y: Single = 0): Single; overload; |
|
function Align( const ThisPosition: TVerticalPosition; const OtherRect: TFloatRectangle; const OtherPosition: TVerticalPosition; const Y: Single = 0): TFloatRectangle; overload; |
|
function ToString: string; |
|
function Translate(const V: TVector2): TFloatRectangle; |
|
function Collides(const R: TFloatRectangle): Boolean; |
|
function CollidesDisc(const DiscCenter: TVector2; const Radius: Single): Boolean; |
|
function ScaleToWidth(const NewWidth: Single): TFloatRectangle; |
|
function ScaleToHeight(const NewHeight: Single): TFloatRectangle; |
|
function ScaleAroundCenter(const Factor: Single): TFloatRectangle; |
|
function ScaleAround0(const Factor: Single): TFloatRectangle; |
|
function FitInside(const R: TFloatRectangle; const AlignHorizontal: THorizontalPosition = hpMiddle; const AlignVertical: TVerticalPosition = vpMiddle): TFloatRectangle; |
|
function Include(const P: TVector2): TFloatRectangle; |
|
function ToX3DVector: TVector4; |
|
class function FromX3DVector(const V: TVector4): TFloatRectangle; static; |
|
function Round: TRectangle; |
|
function Equals(const R: TFloatRectangle): Boolean; overload; |
|
function Equals(const R: TFloatRectangle; const Epsilon: Single): Boolean; overload; |
|
function PerfectlyEquals(const R: TFloatRectangle): Boolean; |
|
class operator + (const R1, R2: TFloatRectangle): TFloatRectangle; |
|
class operator * (const R1, R2: TFloatRectangle): TFloatRectangle; |
|
procedure AddToCoords(const Coords: TVector2List); overload; |
|
procedure AddToCoords(const Coords: TVector3List; const Z: Single); overload; |
Properties
property Right: Single read GetRight; |
|
property Top: Single read GetTop; |
|
property LeftBottom: TVector2 read GetLeftBottom write SetLeftBottom; |
|
property Size: TVector2 read GetSize write SetSize; |
Description
Fields
Left: Single; |
|
This item has no description. |
Bottom: Single; |
|
This item has no description. |
Width: Single; |
|
This item has no description. |
Height: Single; |
|
This item has no description. |
Methods
class function Empty: TFloatRectangle; static; inline; |
|
This item has no description. |
function IsEmpty: Boolean; |
|
This item has no description. |
function Contains(const X, Y: Single): Boolean; overload; |
|
This item has no description. |
function Contains(const Point: TVector2): Boolean; overload; |
|
This item has no description. |
function Contains(const R: TFloatRectangle): Boolean; overload; |
|
This item has no description. |
function Middle: TVector2; deprecated 'use Center'; |
|
Warning: this symbol is deprecated: use Center This item has no description. |
function Center: TVector2; |
|
This item has no description. |
function CenterInside(const W, H: Single): TFloatRectangle; |
|
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: Single): TFloatRectangle; 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: Single): TFloatRectangle; overload; |
|
This item has no description. |
function RemoveLeft(W: Single): TFloatRectangle; |
|
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: Single): TFloatRectangle; |
|
This item has no description. |
function RemoveRight(W: Single): TFloatRectangle; |
|
This item has no description. |
function RemoveTop(H: Single): TFloatRectangle; |
|
This item has no description. |
function GrowLeft(const W: Single): TFloatRectangle; |
|
Returns the rectangle with a number of pixels on given side added. |
function GrowBottom(const H: Single): TFloatRectangle; |
|
This item has no description. |
function GrowRight(const W: Single): TFloatRectangle; |
|
This item has no description. |
function GrowTop(const H: Single): TFloatRectangle; |
|
This item has no description. |
function LeftPart(W: Single): TFloatRectangle; |
|
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: Single): TFloatRectangle; |
|
This item has no description. |
function RightPart(W: Single): TFloatRectangle; |
|
This item has no description. |
function TopPart(H: Single): TFloatRectangle; |
|
This item has no description. |
function AlignCore( const ThisPosition: THorizontalPosition; const OtherRect: TFloatRectangle; const OtherPosition: THorizontalPosition; const X: Single = 0): Single; overload; |
|
Align this rectangle within other rectangle by calculating new value for Left. |
function Align( const ThisPosition: THorizontalPosition; const OtherRect: TFloatRectangle; const OtherPosition: THorizontalPosition; const X: Single = 0): TFloatRectangle; overload; |
|
This item has no description. |
function AlignCore( const ThisPosition: TVerticalPosition; const OtherRect: TFloatRectangle; const OtherPosition: TVerticalPosition; const Y: Single = 0): Single; overload; |
|
Align this rectangle within other rectangle by calculating new value for Bottom. |
function Align( const ThisPosition: TVerticalPosition; const OtherRect: TFloatRectangle; const OtherPosition: TVerticalPosition; const Y: Single = 0): TFloatRectangle; overload; |
|
This item has no description. |
function ToString: string; |
|
This item has no description. |
function Translate(const V: TVector2): TFloatRectangle; |
|
Move the rectangle. Empty rectangle after moving is still an empty rectangle. |
function Collides(const R: TFloatRectangle): Boolean; |
|
Does it have any common part with another rectangle. |
function CollidesDisc(const DiscCenter: TVector2; const Radius: Single): Boolean; |
|
This item has no description. |
function ScaleToWidth(const NewWidth: Single): TFloatRectangle; |
|
This item has no description. |
function ScaleToHeight(const NewHeight: Single): TFloatRectangle; |
|
This item has no description. |
function ScaleAroundCenter(const Factor: Single): TFloatRectangle; |
|
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 ScaleAround0(const Factor: Single): TFloatRectangle; |
|
Scale rectangle position and size around the (0,0) point. |
function FitInside(const R: TFloatRectangle; const AlignHorizontal: THorizontalPosition = hpMiddle; const AlignVertical: TVerticalPosition = vpMiddle): TFloatRectangle; |
|
Scale and align us to fit inside rectangle R, preserving our aspect ratio. |
function Include(const P: TVector2): TFloatRectangle; |
|
Return larger rectangle, so that it includes given point. |
function ToX3DVector: TVector4; |
|
Convert to a 4D vector, like expected by X3D fields OrthoViewpoint.fieldOfView or DirectionalLight.projectionRectangle. |
class function FromX3DVector(const V: TVector4): TFloatRectangle; static; |
|
Convert from a 4D vector, like expected by X3D fields OrthoViewpoint.fieldOfView or DirectionalLight.projectionRectangle. |
function Round: TRectangle; |
|
Round rectangle coordinates, converting TFloatRectangle to TRectangle. |
function Equals(const R: TFloatRectangle): Boolean; overload; |
|
Is another rectangle equal to this one. Floating-point values are compared with an epsilon tolerance. |
function Equals(const R: TFloatRectangle; const Epsilon: Single): Boolean; overload; |
|
Is another rectangle equal to this one. Floating-point values are compared with an epsilon tolerance. |
function PerfectlyEquals(const R: TFloatRectangle): Boolean; |
|
Compare using exact comparison (without any epsilon to tolerate small float differences). |
class operator + (const R1, R2: TFloatRectangle): TFloatRectangle; |
|
Sum of the two rectangles is a bounding rectangle - a smallest rectangle that contains them both. |
class operator * (const R1, R2: TFloatRectangle): TFloatRectangle; |
|
Common part of the two rectangles. |
procedure AddToCoords(const Coords: TVector2List); overload; |
|
Add 4 corners of this rectangle to the list, in CCW order, starting from left-bottom. |
procedure AddToCoords(const Coords: TVector3List; const Z: Single); overload; |
|
Add 4 corners of this rectangle to the list, in CCW order, starting from left-bottom. Set the Z coordinate of all added (3D) points to the one you specify by the Z parameter. |
Properties
property Top: Single read GetTop; |
|
This item has no description. |
property LeftBottom: TVector2 read GetLeftBottom write SetLeftBottom; |
|
This item has no description. |
property Size: TVector2 read GetSize write SetSize; |
|
Alternative way to access Width and Height. Name consistent with TBoxNode.Size, TBox3D.Size. |
Generated by PasDoc 0.16.0-snapshot.