libvisual  0.5.0
Public Member Functions | Public Attributes | List of all members
LV::Rect Class Reference

Class describing an axis-aligned rectangle. More...

#include <libvisual/lv_rectangle.h>

Public Member Functions

 Rect ()
 Creates a new empty Rect.
 
 Rect (int x_, int y_, int width_, int height_)
 Creates a new Rect. More...
 
 Rect (int width_, int height_)
 Creates a new Rect of the given dimensions. More...
 
void set (int x_, int y_, int width_, int height_)
 Sets rectangle extents. More...
 
bool empty () const
 Checks if this rectangle has a non-zero area. More...
 
bool contains (int x_, int y_) const
 Tests if a given point falls within this rectangle. More...
 
bool contains (Rect const &r) const
 Tests if this rectangle completely contains with another. More...
 
bool intersects (Rect const &r) const
 tests if this rectangle intersects with another More...
 
Rect clip (Rect const &r) const
 Clips a rectangle to this rectangle. More...
 
void normalize ()
 Normalizes this rectangle to the origin. More...
 
void normalize_to (Rect const &r)
 Normalizes this rectangle to another. More...
 
void denormalize_point (float fx, float fy, int32_t &x_, int32_t &y_) const
 Transforms a point with relative coordinates in [(0,0), (1,1)] to absolute positions in this rectangle. More...
 
void denormalize_points (float const *fxlist, float const *fylist, int32_t *xlist, int32_t *ylist, unsigned int size) const
 A fast array version of denormalize_point(). More...
 
void denormalize_point_neg (float fx, float fy, int32_t &x_, int32_t &y_) const
 Transform a point with relative coordinates in [(-1,-1), (1,1)] to absolute positions in this rectangle. More...
 
void denormalize_points_neg (float const *fxlist, float const *fylist, int32_t *xlist, int32_t *ylist, unsigned int size) const
 A fast array version of denormalize_point_neg() More...
 

Public Attributes

int x
 
int y
 
int width
 
int height
 

Detailed Description

Class describing an axis-aligned rectangle.

Definition at line 39 of file lv_rectangle.h.

Constructor & Destructor Documentation

LV::Rect::Rect ( int  x_,
int  y_,
int  width_,
int  height_ 
)
inline

Creates a new Rect.

Parameters
xX-coordinate of upper-left corner
yY-coordinate of upper-left corner
widthWidth of rectangle
heightHeight of rectangle

Definition at line 63 of file lv_rectangle.h.

LV::Rect::Rect ( int  width_,
int  height_ 
)
inline

Creates a new Rect of the given dimensions.

Parameters
widthWidth of rectangle
heightHeight of rectangle

Definition at line 73 of file lv_rectangle.h.

Member Function Documentation

Rect LV::Rect::clip ( Rect const &  r) const

Clips a rectangle to this rectangle.

Parameters
rrectangle to clip
Returns
Clipped rectangle

Definition at line 65 of file lv_rectangle.cpp.

bool LV::Rect::contains ( int  x_,
int  y_ 
) const
inline

Tests if a given point falls within this rectangle.

Parameters
xx position of point
yy position of point
Returns
true if within rectangle, false otherwise

Definition at line 109 of file lv_rectangle.h.

bool LV::Rect::contains ( Rect const &  r) const

Tests if this rectangle completely contains with another.

Parameters
rrectangle to test containment
Returns
true if given rectangle completely contained, false otherwise

Definition at line 48 of file lv_rectangle.cpp.

void LV::Rect::denormalize_point ( float  fx,
float  fy,
int32_t &  x_,
int32_t &  y_ 
) const
inline

Transforms a point with relative coordinates in [(0,0), (1,1)] to absolute positions in this rectangle.

(0,0) and (1,1) are respectively mapped to the top-left and bottom-right corners.

Note
Out of range coordinates are clamped.
See Also
denormalize_points()
Parameters
fxNormalized X coordinate of point
fyNormalized Y coordinate of point
xInteger variable to store the absolute X coordinate
yInteger variable to store the absolute Y coordinate

Definition at line 179 of file lv_rectangle.h.

void LV::Rect::denormalize_point_neg ( float  fx,
float  fy,
int32_t &  x_,
int32_t &  y_ 
) const
inline

Transform a point with relative coordinates in [(-1,-1), (1,1)] to absolute positions in this rectangle.

(-1,-1) and (1,1) are respectively mapped to the top-left and bottom-right corners.

Note
Out of range coordinates are clamped.
See Also
denormalize_points()
Parameters
fxNormalized X coordinate of point
fyNormalized Y coordinate of point
xInteger variable to store the absolute X coordinate
yInteger variable to store the absolute Y coordinate

Definition at line 216 of file lv_rectangle.h.

void LV::Rect::denormalize_points ( float const *  fxlist,
float const *  fylist,
int32_t *  xlist,
int32_t *  ylist,
unsigned int  size 
) const

A fast array version of denormalize_point().

Note
Unlike denormalize_point(), out of range input coordinates are NOT clamped for performance reasons.
Parameters
fxlistinput array of x coordinates, each in [0.0, 1.0]
fylistinput array of y coordinates, each in [0.0, 1.0]
xlistoutput array of x coordinates
ylistoutput array of y coordinates
sizenumber of points

Definition at line 95 of file lv_rectangle.cpp.

void LV::Rect::denormalize_points_neg ( float const *  fxlist,
float const *  fylist,
int32_t *  xlist,
int32_t *  ylist,
unsigned int  size 
) const

A fast array version of denormalize_point_neg()

Note
Unlike denormalize_point_neg(), out of range input coordinates are NOT clamped for performance reasons.
Parameters
fxlistinput array of x coordinates, each in [-1.0, 1.0]
fylistinput array of y coordinates, each in [-1,0, 1.0]
xlistoutput array of x coordinates
ylistoutput array of y coordinates
sizenumber of points

Definition at line 107 of file lv_rectangle.cpp.

bool LV::Rect::empty ( ) const
inline

Checks if this rectangle has a non-zero area.

Returns
true is rectangle has a non-zero area, false otherwise

Definition at line 96 of file lv_rectangle.h.

bool LV::Rect::intersects ( Rect const &  r) const

tests if this rectangle intersects with another

Parameters
rrectangle to test intersection with
Returns
true if rectangles intersect, false otherwise

Definition at line 31 of file lv_rectangle.cpp.

Referenced by clip().

void LV::Rect::normalize ( )
inline

Normalizes this rectangle to the origin.

The top-corner will be set to (0, 0)

Parameters
srcrectangle to normalize to

Definition at line 148 of file lv_rectangle.h.

void LV::Rect::normalize_to ( Rect const &  r)
inline

Normalizes this rectangle to another.

The top-corner will be set to that of the given rectangle.

Parameters
srcrectangle to normalize to

Definition at line 159 of file lv_rectangle.h.

void LV::Rect::set ( int  x_,
int  y_,
int  width_,
int  height_ 
)
inline

Sets rectangle extents.

Parameters
xX-coordinate of upper-left corner
yY-coordinate of upper-left corner
widthWidth of rectangle
heightHeight of rectangle

Definition at line 85 of file lv_rectangle.h.


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