GlistEngine
Loading...
Searching...
No Matches
gRect Class Reference

#include <gRect.h>

Public Member Functions

 gRect ()
 
 gRect (int left, int top, int right, int bottom)
 
 gRect (const gRect &r)
 
virtual ~gRect ()
 
int centerX () const
 
int centerY () const
 
float exactCenterX () const
 
float exactCenterY () const
 
void set (int left, int top, int right, int bottom)
 
void set (const gRect &r)
 
bool intersects (int left, int top, int right, int bottom) const
 
bool intersects (const gRect &r) const
 
bool contains (int left, int top, int right, int bottom) const
 
bool contains (const gRect &r) const
 
bool contains (int x, int y) const
 
int left () const
 
int top () const
 
int right () const
 
int bottom () const
 
int getWidth () const
 
int getHeight () const
 
void moveX (int speedX)
 
void moveY (int speedY)
 
void moveX (float speedX)
 
void moveY (float speedY)
 

Static Public Member Functions

static bool intersects (int left1, int top1, int right1, int bottom1, int left2, int top2, int right2, int bottom2)
 
static bool intersects (const gRect &r1, const gRect &r2)
 
static bool contains (int left1, int top1, int right1, int bottom1, int left2, int top2, int right2, int bottom2)
 
static bool contains (const gRect &r1, const gRect &r2)
 

Detailed Description

gRect holds six integer for a rectangle. The rectangle is represented by the coordinates of its four edges(left, top, right, bottom). These fields can be accessed via their respective functions(e.g. to acces left edge of the rectangle use left()). Use getWidth() and getHeight() to retrieve the rectangles width and height. To set edges of the rectangle use one of the set function.

Constructor & Destructor Documentation

◆ gRect() [1/3]

gRect::gRect ( )

Creates empty rectangle

◆ gRect() [2/3]

gRect::gRect ( int  left,
int  top,
int  right,
int  bottom 
)

Creates rectangle with given edges.

Parameters
leftLeft edge of the rectangle to be created.
topTop edge of the rectangle to be created.
rightRight edge of the rectangle to be created.
bottomBottom edge of the rectangle to be created.

◆ gRect() [3/3]

gRect::gRect ( const gRect r)

Creates copy of the given rectangle.

Parameters
rRectangle to be copied.

◆ ~gRect()

virtual gRect::~gRect ( )
virtual

Member Function Documentation

◆ bottom()

int gRect::bottom ( ) const

Returns bottom edge of the rectangle.

Returns
Bottom edge of the rectangle.

◆ centerX()

int gRect::centerX ( ) const

Returns x(horizontal) center coordinate of rectangle but as integer value.

Returns
x center of rectangle.

◆ centerY()

int gRect::centerY ( ) const

Returns y(vertical) center coordinate of rectangle but as integer value.

Returns
y center of rectangle.

◆ contains() [1/5]

bool gRect::contains ( const gRect r) const

Checks if given rectangles edges are inside or equal of the current rectangle.

Parameters
rRectangle to be check.
Returns
true if given rectangle is inside of current rectangle false if not.

◆ contains() [2/5]

static bool gRect::contains ( const gRect r1,
const gRect r2 
)
static

Checks if second rectangles edges are inside or equal of the first rectangle.

Parameters
r1First rectangle to be check.
r2Second rectangle to be check.
Returns
true if second rectangle is inside of first rectangle false if not.

◆ contains() [3/5]

bool gRect::contains ( int  left,
int  top,
int  right,
int  bottom 
) const

Checks if given rectangles edges are inside or equal of the current rectangle.

Parameters
leftLeft edge of the given rectangle
topTop edge of the given rectangle
rightRight edge of the given rectangle
bottomBottom edge of the given rectangle
Returns
true if given rectangle is inside of current rectangle false if not.

◆ contains() [4/5]

static bool gRect::contains ( int  left1,
int  top1,
int  right1,
int  bottom1,
int  left2,
int  top2,
int  right2,
int  bottom2 
)
static

Checks if second rectangles edges are inside or equal of the first rectangle.

Parameters
left1Left edge of the first rectangle
top1Top edge of the first rectangle
right1Right edge of the first rectangle
bottom1Bottom edge of the first rectangle
left2Left edge of the second rectangle
top2Top edge of the second rectangle
right2Right edge of the second rectangle
bottom2Bottom edge of the second rectangle
Returns
true if second rectangle is inside of first rectangle false if not.

◆ contains() [5/5]

bool gRect::contains ( int  x,
int  y 
) const

Checks if given point are inside of the current rectangle.

Parameters
xX Position of the given point
yY Position of the given point
Returns
true if given point is inside of current rectangle false if not.

◆ exactCenterX()

float gRect::exactCenterX ( ) const

Returns x(horizontal) exact center coordinate of rectangle as float value.

Returns
x exact center of rectangle.

◆ exactCenterY()

float gRect::exactCenterY ( ) const

Returns y(vertical) exact center coordinate of rectangle as float value.

Returns
y exact center of rectangle.

◆ getHeight()

int gRect::getHeight ( ) const

Returns height of the rectangle.

Returns
Height of the rectangle.

◆ getWidth()

int gRect::getWidth ( ) const

Returns width of the rectangle.

Returns
Width of the rectangle.

◆ intersects() [1/4]

bool gRect::intersects ( const gRect r) const

Checks whether of intersection with given rectangle.

Parameters
rRectangle to be check.
Returns
true if there is intersection false if not.

◆ intersects() [2/4]

static bool gRect::intersects ( const gRect r1,
const gRect r2 
)
static

Checks whether of intersection given 2 rectangle.

Parameters
r1First rectangle to be check.
r2Second rectangle to be check.
Returns
true if there is intersection false if not.

◆ intersects() [3/4]

bool gRect::intersects ( int  left,
int  top,
int  right,
int  bottom 
) const

Checks whether of intersection with given rectangle.

Parameters
leftLeft edge of the given rectangle
topTop edge of the given rectangle
rightRight edge of the given rectangle
bottomBottom edge of the given rectangle
Returns
true if there is intersection false if not.

◆ intersects() [4/4]

static bool gRect::intersects ( int  left1,
int  top1,
int  right1,
int  bottom1,
int  left2,
int  top2,
int  right2,
int  bottom2 
)
static

Checks whether of intersection given 2 rectangle.

Parameters
left1Left edge of the first rectangle
top1Top edge of the first rectangle
right1Right edge of the first rectangle
bottom1Bottom edge of the first rectangle
left2Left edge of the second rectangle
top2Top edge of the second rectangle
right2Right edge of the second rectangle
bottom2Bottom edge of the second rectangle
Returns
true if there is intersection false if not.

◆ left()

int gRect::left ( ) const

Returns left edge of the rectangle.

Returns
Left edge of the rectangle.

◆ moveX() [1/2]

void gRect::moveX ( float  speedX)

Move the rectangle on X Axis with amound of speedX

◆ moveX() [2/2]

void gRect::moveX ( int  speedX)

Move the rectangle on X Axis with amound of speedX

◆ moveY() [1/2]

void gRect::moveY ( float  speedY)

Move the rectangle on Y Axis with amound of speedY

◆ moveY() [2/2]

void gRect::moveY ( int  speedY)

Move the rectangle on Y Axis with amound of speedY

◆ right()

int gRect::right ( ) const

Returns right edge of the rectangle.

Returns
Right edge of the rectangle.

◆ set() [1/2]

void gRect::set ( const gRect r)

Sets edges of the rectangle with the given rectangle

Parameters
rRectangle to be set

◆ set() [2/2]

void gRect::set ( int  left,
int  top,
int  right,
int  bottom 
)

Sets edges of the rectangle.

Parameters
leftLeft edge to be set
topTop edge to be set
rightRight edge to be set
bottomBottom edge to be set

◆ top()

int gRect::top ( ) const

Returns top edge of the rectangle.

Returns
Top edge of the rectangle.

The documentation for this class was generated from the following file: