Main Page   Namespace List   Compound List   File List   Namespace Members   Compound Members   File Members  

ZE::ZRect Class Reference

#include <ZE_ZRect.h>

List of all members.


Detailed Description

ZRect Rectangle class, used to define a rectangular area or perform operations on the defined area.


Public Methods

 ZRect ()
 Default constructor for ZRect.

 ZRect (float x, float y, float width, float height)
 Constructor for ZRect that takes inital values.

 ZRect (const SDL_Rect &rect)
 Constructor for ZRect that uses an SDL_Rect.

 ZRect (const ZRect &rhs)
 Copy constructor for ZRect.

const ZRect & operator= (const ZRect &rhs)
 Overload for = operator with ZRect.

virtual ~ZRect ()
 Virtual Destructor.

bool operator< (const ZRect &rhs) const
 Overload for < operator with ZRect, based upon location then size.

void Draw (Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha=255) const
 Draw rectangle. (filled).

void Move (float x, float y)
 Changes the location of the rectangle.

void MoveRel (float xMove, float yMove)
 Changes the location of the rectangle based upon the current location.

void Resize (float width, float height)
 Resize rectangle.

void ResizeRel (float widthChange, float heightChange)
 Grows or shrinks current rectangle.

bool Intersects (const ZRect &rect) const
 Check if one ZRect intersects another.

bool Contains (float x, float y) const
 Check if a rectangle contains a given point.

bool Contains (const ZRect &rect) const
 Check if a rectangle contains a given point.

ZRect Intersection (const ZRect &rect) const
 Finds intersection of two rectangles.

SDL_Rect SDLrect () const
 Returns an SDL_Rect representing the rectangle.

float X () const
 Returns X Location.

float Y () const
 Returns Y Location.

float Left () const
 Return position of left side.

float Right () const
 Return position of right side.

float Top () const
 Return position of top side.

float Bottom () const
 Return position of bottom side.

float Width () const
 Returns Width.

float Height () const
 Returns Height.


Protected Attributes

float rX
 X Position of top left corner of rectangle.

float rY
 Y Position of top left corner of rectangle.

float rWidth
 Width of Rectangle.

float rHeight
 Height of Rectangle.


Constructor & Destructor Documentation

ZE::ZRect::ZRect  
 

Default constructor, initializes all values to zero.

ZE::ZRect::ZRect float    x,
float    y,
float    width,
float    height
 

Constructor for ZRect that takes inital values for all four members.

Parameters:
x Value for x position.
y Value for y position.
width Value for width.
height Value for height.

ZE::ZRect::ZRect const SDL_Rect &    rect
 

Constructor for ZRect that initializes from an SDL_Rect.

Parameters:
rect SDL_Rect to intialize from.

ZE::ZRect::ZRect const ZRect &    rhs
 

Takes a ZRect and constructs a new identical rectangle.

Parameters:
rhs Rectangle to construct from.

ZE::ZRect::~ZRect   [virtual]
 

Virtual destructor making future inheritance safe.


Member Function Documentation

const ZRect & ZE::ZRect::operator= const ZRect &    rhs
 

Copies all values from one ZRect into another.

Parameters:
rhs Rectangle to copy values from.
Returns:
New value of the ZRect.

bool ZE::ZRect::operator< const ZRect &    rhs const
 

Rectangles are sorted by y value, followed by x value, if they start at the same place, the smaller of the two is deemed less than the other.

Parameters:
rhs Rectangle to compare.
Returns:
True if this rectangle is smaller than the rhs rectangle, false otherwise.

void ZE::ZRect::Draw Uint8    red,
Uint8    green,
Uint8    blue,
Uint8    alpha = 255
const
 

Draw the ZRect, this function is mainly provided for testing purposes.

Parameters:
red Red component of color (0-255).
green Green component of color (0-255).
blue Blue component of color (0-255).
alpha Alpha component of color (0-255).

void ZE::ZRect::Move float    x,
float    y
 

Changes the current x,y position of the rectangle.

Parameters:
x New x position for rectangle.
y New y position for rectangle.

void ZE::ZRect::MoveRel float    xMove,
float    yMove
 

Changes the current x,y position of the rectangle relative to the current location.

Parameters:
xMove Offset for new x position from current.
yMove Offset for new y position from current.

void ZE::ZRect::Resize float    width,
float    height
 

Changes the current width and height of the rectangle.

Parameters:
width New width for rectangle.
height New height for rectangle.

void ZE::ZRect::ResizeRel float    widthChange,
float    heightChange
 

Changes the current width and height of the rectangle based upon current values.

Parameters:
widthChange Amount to add or subtract from width.
heightChange Amount to add or subtract from height.

bool ZE::ZRect::Intersects const ZRect &    rect const
 

Checks for overlap and returns boolean value based on if overlap exists.

Parameters:
rect Rectangle to check for intersection with.
Returns:
True if intersection occured, false otherwise.

bool ZE::ZRect::Contains float    x,
float    y
const
 

Checks point against boundaries of rectangle and returns result.

Parameters:
x X value of point to check.
y Y value of poitn to check.
Returns:
Boolean variable, true if point is inside rectangle, false otherwise.

bool ZE::ZRect::Contains const ZRect &    rect const
 

Checks point against boundaries of rectangle and returns result.

Parameters:
rect Rectangle to check for point.
Returns:
Boolean variable, true if point is inside rectangle, false otherwise.

ZRect ZE::ZRect::Intersection const ZRect &    rect const
 

Checks for intersection, and returns rectangle where the two rectangles intersect.

Parameters:
rect Rectangle to check intersection with.
Returns:
ZRect describing intersection area.

SDL_Rect ZE::ZRect::SDLrect   const
 

Makes a SDL_Rect representing the rectangle, for use where functions require an SDL_Rect.

Returns:
SDL_Rect representing the ZRect.

float ZE::ZRect::X   const
 

Access private X location member.

Returns:
Value of mX.

float ZE::ZRect::Y   const
 

Access private Y location member.

Returns:
Value of mY.

float ZE::ZRect::Left   const
 

Find X position of left side of rectangle.

Returns:
X position of left side.

float ZE::ZRect::Right   const
 

Find X position of right side of rectangle.

Returns:
X position of right side.

float ZE::ZRect::Top   const
 

Find Y position of top side of rectangle.

Returns:
Y position of top side.

float ZE::ZRect::Bottom   const
 

Find Y position of left side of rectangle.

Returns:
Y position of bottom side.

float ZE::ZRect::Width   const
 

Access private width member.

Returns:
Value of mWidth.

float ZE::ZRect::Height   const
 

Access private height member.

Returns:
Value of mHeight.


The documentation for this class was generated from the following files:
Generated on Sun Apr 27 14:53:40 2003 for ZEngine by doxygen1.3-rc2