Object TRectangle
Unit
CastleRectangles
Declaration
type TRectangle = object(TObject)
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.
Hierarchy
Overview
Fields
Methods
Properties
Description
Fields
 |
Left: Integer; |
|
 |
Bottom: Integer; |
|
 |
Width: Cardinal; |
|
 |
Height: Cardinal; |
|
 |
internal const Empty: TRectangle = (Left: 0; Bottom: 0; Width: 0; Height: 0); |
|
Methods
 |
function Contains(const X, Y: Integer): boolean; |
|
 |
function Center(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; |
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; |
|
 |
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 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 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 LeftPart ) then the unmodified rectangle is returned.
|
Properties
 |
property Right: Integer read GetRight; |
Right and Top pixels are 1 pixel *outside* of the rectangle.
|
 |
property Top: Integer read GetTop; |
|
 |
property LeftBottom: TVector2Integer read GetLeftBottom write SetLeftBottom; |
|
Generated by PasDoc 0.13.0 on 2014-04-30 22:06:44
|