Logo Search packages:      
Sourcecode: scummvm version File versions

Common::Rect Struct Reference

#include <rect.h>

List of all members.


Detailed Description

simple class for handling a rectangular zone.

This small class is an helper for rectangles. Note: This implementation is built around the assumption that (top,left) is part of the rectangle, but (bottom,right) is not! This is reflected in various methods, including contains(), intersects() and others.

Another very wide spread approach to rectangle classes treats (bottom,right) also as a part of the rectangle.

Coneptually, both are sound, but the approach we use saves many intermediate computations (like computing the height in our case is done by doing this: height = bottom - top; while in the alternate system, it would be height = bottom - top + 1;

When writing code using our Rect class, always keep this principle in mind!

Definition at line 64 of file rect.h.


Public Member Functions

void clip (int maxw, int maxh)
void clip (const Rect &r)
bool contains (const Point &p) const
 check if given point is inside this rectangle
bool contains (int16 x, int16 y) const
 check if given position is inside this rectangle
void extend (const Rect &r)
 extend this rectangle so that it contains r
void grow (int16 offset)
 extend this rectangle in all four directions by the given number of pixels
int16 height () const
bool intersects (const Rect &r) const
 check if given rectangle intersects with this rectangle
bool isValidRect () const
void moveTo (const Point &p)
void moveTo (int16 x, int16 y)
 Rect (int16 x1, int16 y1, int16 x2, int16 y2)
 Rect (int16 w, int16 h)
int16 width () const

Public Attributes

int16 bottom
int16 left
 The point at the top left of the rectangle (part of the rect).
int16 right
 The point at the bottom right of the rectangle (not part of the rect).
int16 top

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

Generated by  Doxygen 1.6.0   Back to index