Entire Class Index | Main Class Index | Cross Index | Global Index

# Class CL_Rect

Rect Class
Contained in: global
Derived from: none
Derived by: none
Group: Core (Math)

#include <ClanLib/core.h>

### public function member index:
### Construction:
`` | `CL_Rect` | `(`int` `nx1` = 0, `int` `ny1` = 0, `int` `nx2` = 0, `int` `ny2` = 0)`;
`` | `CL_Rect` | `(`const` `CL_Rect`& `rect`)`;
### Operations:
``static` `CL_Rect`` | `center` | `(`int` `center_x`, `int` `center_y`, `int` `width`, `int` `height`)`;
``static` `CL_Rect`` | `left` | `(`int` `x`, `int` `y`, `int` `width`, `int` `height`, `bool` `center_vert` = true)`;
``static` `CL_Rect`` | `right` | `(`int` `x`, `int` `y`, `int` `width`, `int` `height`, `bool` `center_vert` = true)`;
``void`` | `move` | `(`int` `delta_x`, `int` `delta_y`)`;
``void`` | `normalize` | `()`;
### Attributes:
``bool`` | `inside` | `(`int` `x`, `int` `y`) `const``;
``int`` | `get_width` | `() `const``;
``int`` | `get_height` | `() `const``;
``void`` | `clear` | `()`;
### Operators:
``bool`` | `operator``==` | `(`const` `CL_Rect`& `rect`) `const``;

## Description:

## Function Member Descriptions:

CL_Rect::CL_Rect - Rect Constructor
`` `CL_Rect``(`int` `nx1` = 0, `int` `ny1` = 0, `int` `nx2` = 0, `int` `ny2` = 0)`;

> nx1 - right constraint
> ny1 - bottom constraint
> nx2 - left constraint
> ny2 - top constraint

CL_Rect::CL_Rect - Rect Copy Constructor
`` `CL_Rect``(`const` `CL_Rect`& `rect`)`;

> rect - The rectangle to copy

CL_Rect::center - Creates a rectangle around the given centre
``static` `CL_Rect`` `center``(`int` `center_x`, `int` `center_y`, `int` `width`, `int` `height`)`;

> center_x - The x coord of the centre
> center_y - the y coord of the centre
> width - The width of the rectangle
> height - The height of the rectangle
> Returns - The centred rectangle

CL_Rect::clear - Sets all rectangle dimensions/points to 0.
``void`` `clear``()`;

CL_Rect::get_height - Get Height
``int`` `get_height``() `const``;

> Returns - Height of rectangle

CL_Rect::get_width - Get Width
``int`` `get_width``() `const``;

> Returns - Width of rectangle

CL_Rect::inside - Determine if a point is inside the rectangle
``bool`` `inside``(`int` `x`, `int` `y`) `const``;

> x - the x coord of the point
> y - the y coord of the point
> Returns - True if the point is in the rectangle or on it's border.

CL_Rect::left - Align the rectangle left
``static` `CL_Rect`` `left``(`int` `x`, `int` `y`, `int` `width`, `int` `height`, `bool` `center_vert` = true)`;

> x - the left edge of the rectangle
> y - the bottom of the rectangle
> width - the width of the rectangle
> height - the height of the rectangle
> centre_vert - centre the rectangle around the y coord
> Returns - Left aligned rectangle

CL_Rect::move - Move the rectangle
``void`` `move``(`int` `delta_x`, `int` `delta_y`)`;

> delta_x - Distance to move rectangle on x-axis
> delta_y - Distance to move rectangle on y-axis

CL_Rect::normalize - Normalize rectangle. Ensures that x1<x2 and y1<y2.
``void`` `normalize``()`;

CL_Rect::operator == - Equivalancy operator
``bool`` `operator``==` `(`const` `CL_Rect`& `rect`) `const``;

CL_Rect::right - Align the rectangle right
``static` `CL_Rect`` `right``(`int` `x`, `int` `y`, `int` `width`, `int` `height`, `bool` `center_vert` = true)`;

> x - the right edge of the rectangle
> y - the bottom of the rectangle
> width - the width of the rectangle
> height - the height of the rectangle
> centre_vert - centre the rectangle around the y coord
> Returns - Right aligned rectangle

## Variable Member Descriptions:

CL_Rect::x1 - Left x coord
``int`` ``x1`;`

CL_Rect::x2 - Right x coord
``int`` ``x2`;`

CL_Rect::y1 - Bottom y coord
``int`` ``y1`;`

CL_Rect::y2 - Top y coord
``int`` ``y2`;`