class Rect

A class that represents a rectangular area on the screen.

Global Functions

Rect FromPoint (const Point, int, int)Returns a new rectangle created from the given point and width, height.
Rect FromSize (const int, const int)Returns a new rectangle at position (0,0) and of the given width, height.

Constructors

Rect ()Constructs a new empty rectangle (0,0,0,0).
Rect (const Rect)Constructs a rectangle that is a copy of the given rectangle.
Rect (const Point, const Point)Constructs a rectangle from the specified upper-left and bottom-right points.
Rect (const int, const int, const int, const int)Constructs a rectangle from the given left, top, right and bottom coordinates.

Methods

AddPoint (const Point)Moves this rectangle by adding the specified Point.
AddRect (const Rect)Moves and resizes this Rect by adding the specified Rect.
CenterIn (const Rect)Centers this rectangle inside the given rectangle.
int ClipDestination (Rect, Point)Clip the given Rect (!) based on this Rect and move the given Point (!) if neccessary.
int ClipInside (const Rect)Clips this rectangle's borders to the insides of the specified rectangle.
Combine (const Rect)Combines the two rectangles into a larger one.
HCenterIn (const Rect)Horizontally centers this rectangle inside the given rectangle.
int IsEqual (const Rect)Returns true if this rectangle exactly matches the given rectangle.
int IsInside (const Rect)Returns true if this rectangle is fully inside the bounds of the given rectangle.
int IsOverlapping (const Rect)Returns true if this rectangle intersects with the given rectangle.
MoveTo (const Point)Moves this rectangle to the specified coordinates.
Offset (const int, const int)Move this rectangle by the specified offsets.
Resize (const int, const int)Resizes this rectangle to the specified width, height.
ResizeBy (const int, const int)Resizes this rectangle by the specified offsets.
Scale (const int, const int)Grows or shrinks this rectangle symmetrically by the specified offsets.
SubPoint (const Point)Moves this rectangle by subtracting the specified Point.
SubRect (const Rect)Moves and resizes this Rect by subtracting the specified Rect.
VCenterIn (const Rect)Vertically centers this rectangle inside the given rectangle.

Properties

int Bottom ()Returns the bottom coordinate of the Rect.
Bottom (const int)Sets the bottom coordinate of the Rect.
Point BottomRight ()Returns the bottom-right corner of this Rect as a new Point.
int Empty ()Returns true if this Rect's area is zero, false if otherwise.
int Height ()Returns the height of this Rect.
int Left ()Returns the left coordinate of the Rect.
Left (const int)Sets the left coordinate of the Rect.
int Right ()Returns the right coordinate of the Rect.
Right (const int)Sets the right coordinate of the Rect.
int Top ()Returns the top coordinate of the Rect.
Top (const int)Sets the top coordinate of the Rect.
Point TopLeft ()Returns the top-left corner of this Rect as a new Point.
int Width ()Returns the width of this Rect.

Reference

function Rect FromPoint (const Point pt, int w, int h)

Returns a new rectangle created from the given point and width, height.


function Rect FromSize (const int w, const int h)

Returns a new rectangle at position (0,0) and of the given width, height.


method Rect ()

Constructs a new empty rectangle (0,0,0,0).


method Rect (const Rect src)

Constructs a rectangle that is a copy of the given rectangle.


method Rect (const Point tl, const Point br)

Constructs a rectangle from the specified upper-left and bottom-right points.


method Rect (const int l, const int t, const int r, const int b)

Constructs a rectangle from the given left, top, right and bottom coordinates.


method AddPoint (const Point src)

Moves this rectangle by adding the specified Point.


method AddRect (const Rect src)

Moves and resizes this Rect by adding the specified Rect.


method CenterIn (const Rect src)

Centers this rectangle inside the given rectangle.


method int ClipDestination (Rect dest, Point src)

Clip the given Rect (!) based on this Rect and move the given Point (!) if neccessary.

This method is specialized for clipping bitmaps. The 'src' point repesents the starting point of the blit operation in the bitmap, 'dest' will be the destination rectangle of the blit operation, representing the still visible portion of the image.


method int ClipInside (const Rect src)

Clips this rectangle's borders to the insides of the specified rectangle.


method Combine (const Rect src)

Combines the two rectangles into a larger one.

The new rectangle's area will completely cover both source rectangles.


method HCenterIn (const Rect src)

Horizontally centers this rectangle inside the given rectangle.


method int IsEqual (const Rect src)

Returns true if this rectangle exactly matches the given rectangle.


method int IsInside (const Rect src)

Returns true if this rectangle is fully inside the bounds of the given rectangle.


method int IsOverlapping (const Rect src)

Returns true if this rectangle intersects with the given rectangle.


method MoveTo (const Point src)

Moves this rectangle to the specified coordinates.


method Offset (const int x, const int y)

Move this rectangle by the specified offsets.


method Resize (const int w, const int h)

Resizes this rectangle to the specified width, height.


method ResizeBy (const int dx, const int dy)

Resizes this rectangle by the specified offsets.


method Scale (const int dx, const int dy)

Grows or shrinks this rectangle symmetrically by the specified offsets.


method SubPoint (const Point src)

Moves this rectangle by subtracting the specified Point.


method SubRect (const Rect src)

Moves and resizes this Rect by subtracting the specified Rect.


method VCenterIn (const Rect src)

Vertically centers this rectangle inside the given rectangle.


accessor int Bottom ()

Returns the bottom coordinate of the Rect.


accessor Bottom (const int)

Sets the bottom coordinate of the Rect.


accessor Point BottomRight ()

Returns the bottom-right corner of this Rect as a new Point.


accessor int Empty ()

Returns true if this Rect's area is zero, false if otherwise.

Only the rectangle's area is taken into account, it's position does not matter.


accessor int Height ()

Returns the height of this Rect.


accessor int Left ()

Returns the left coordinate of the Rect.


accessor Left (const int)

Sets the left coordinate of the Rect.


accessor int Right ()

Returns the right coordinate of the Rect.


accessor Right (const int)

Sets the right coordinate of the Rect.


accessor int Top ()

Returns the top coordinate of the Rect.


accessor Top (const int)

Sets the top coordinate of the Rect.


accessor Point TopLeft ()

Returns the top-left corner of this Rect as a new Point.


accessor int Width ()

Returns the width of this Rect.