Castle Game EngineIntroduction Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers
|
Record TFloatRectangle
Unit
CastleRectangles
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
Methods
Properties
property Right: Single read GetRight ; |
property Top: Single read GetTop ; |
Description
Fields
Left: Single; |
// Commented out – see TRectangle comments. procedure SetRight(const Value: Single); procedure SetTop(const Value: Single);
|
Bottom: Single; |
// Commented out – see TRectangle comments. procedure SetRight(const Value: Single); procedure SetTop(const Value: Single);
|
Methods
function IsEmpty: boolean; |
|
function Contains(const X, Y: Single): boolean; overload; |
|
function Contains(const Point: TVector2): boolean; overload; |
|
function Middle: TVector2; deprecated 'use Center'; |
Warning: this symbol is deprecated: use Center |
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 ToString: string; |
|
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; |
|
function ScaleAround0(const Factor: Single): TFloatRectangle; |
Scale rectangle position and size around the (0,0) 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.
|
Properties
property Right: Single read GetRight ; |
Right and top coordinates of the rectangle. Right is simply the Left + Width , Top is simply the Bottom + Height .
Note: If you use this for drawing, and the values of Left, Bottom, Width, Height are actually integers (or close to integers), then the pixel with (Round(Right ), Round(Top)) coordinates is actually *outside* of the rectangle (by 1 pixel). That's because the rectangle starts at the pixel (Round(Left), Round(Bottom)) and spans the (Round(Width), Round(Height)) pixels.
|
property Top: Single read GetTop ; |
|
Generated by PasDoc 0.15.0.
|