Pepper_47_C++_interfaces
Public Member Functions | List of all members
pp::FloatRect Class Reference

#include <rect.h>

Collaboration diagram for pp::FloatRect:
Collaboration graph

Public Member Functions

 FloatRect ()
 
 FloatRect (const PP_FloatRect &rect)
 
 FloatRect (float w, float h)
 
 FloatRect (float x, float y, float w, float h)
 
 FloatRect (const FloatSize &s)
 
 FloatRect (const FloatPoint &origin, const FloatSize &size)
 
 ~FloatRect ()
 Destructor. More...
 
 operator PP_FloatRect () const
 
const PP_FloatRect & pp_float_rect () const
 
PP_FloatRect & pp_float_rect ()
 
float x () const
 
void set_x (float in_x)
 
float y () const
 
void set_y (float in_y)
 
float width () const
 
void set_width (float w)
 
float height () const
 
void set_height (float h)
 
FloatPoint point () const
 
void set_point (const FloatPoint &origin)
 
FloatSize Floatsize () const
 
void set_size (const FloatSize &s)
 
float right () const
 
float bottom () const
 
void SetRect (float x, float y, float w, float h)
 
void SetRect (const PP_FloatRect &rect)
 
void Inset (float horizontal, float vertical)
 
void Inset (float left, float top, float right, float bottom)
 
void Offset (float horizontal, float vertical)
 
void Offset (const FloatPoint &point)
 
bool IsEmpty () const
 
bool Contains (float point_x, float point_y) const
 
bool Contains (const FloatPoint &point) const
 
bool Contains (const FloatRect &rect) const
 
bool Intersects (const FloatRect &rect) const
 
FloatRect Intersect (const FloatRect &rect) const
 
FloatRect Union (const FloatRect &rect) const
 
FloatRect Subtract (const FloatRect &rect) const
 
FloatRect AdjustToFit (const FloatRect &rect) const
 
FloatPoint CenterPoint () const
 
bool SharesEdgeWith (const FloatRect &rect) const
 

Detailed Description

A 2 dimensional rectangle. A rectangle is represented by x and y (which identifies the upper-left corner of the rectangle), width, and height.

Definition at line 401 of file rect.h.

Constructor & Destructor Documentation

pp::FloatRect::FloatRect ( )
inline

The default constructor. Creates a Rect in the upper-left at 0.0f,0.0f with height and width of 0.0f.

Definition at line 406 of file rect.h.

Referenced by AdjustToFit(), Intersect(), Subtract(), and Union().

pp::FloatRect::FloatRect ( const PP_FloatRect &  rect)
inline

A constructor accepting a reference to a PP_FloatRect and converting the PP_FloatRect to a FloatRect. This is an implicit conversion constructor.

Parameters
[in]rectA PP_FloatRect.

Definition at line 418 of file rect.h.

References set_height(), set_width(), set_x(), and set_y().

pp::FloatRect::FloatRect ( float  w,
float  h 
)
inline

A constructor accepting two float values for width and height and converting them to a FloatRect in the upper-left starting coordinate of 0.0f, 0.0f.

Parameters
[in]wAn float value representing a width.
[in]hAn float value representing a height.

Definition at line 431 of file rect.h.

References set_height(), set_width(), set_x(), and set_y().

pp::FloatRect::FloatRect ( float  x,
float  y,
float  w,
float  h 
)
inline

A constructor accepting four float values for width, height, x, and y.

Parameters
[in]xAn float value representing a horizontal coordinate of a point, starting with 0.0f as the left-most coordinate.
[in]yAn float value representing a vertical coordinate of a point, starting with 0.0f as the top-most coordinate.
[in]wAn float value representing a width.
[in]hAn float value representing a height.

Definition at line 446 of file rect.h.

References set_height(), set_width(), set_x(), and set_y().

pp::FloatRect::FloatRect ( const FloatSize s)
inlineexplicit

A constructor accepting a pointer to a FloatSize and converting the FloatSize to a FloatRect in the upper-left starting coordinate of 0.0f,0.0f.

Parameters
[in]sA pointer to a FloatSize.

Definition at line 458 of file rect.h.

References set_size(), set_x(), and set_y().

pp::FloatRect::FloatRect ( const FloatPoint origin,
const FloatSize size 
)
inline

A constructor accepting a pointer to a FloatPoint representing the origin of the rectangle and a pointer to a FloatSize representing the height and width.

Parameters
[in]originA pointer to a FloatPoint representing the upper-left starting coordinate.
[in]sizeA pointer to a FloatSize representing the height and width.

Definition at line 472 of file rect.h.

References set_point(), and set_size().

pp::FloatRect::~FloatRect ( )
inline

Destructor.

Definition at line 478 of file rect.h.

Member Function Documentation

FloatRect pp::FloatRect::AdjustToFit ( const FloatRect rect) const

AdjustToFit() fits as much of the receiving rectangle within the supplied rectangle as possible, returning the result. For example, if the receiver had a x-location of 2 and a width of 4, and the supplied rectangle had an x-location of 0 with a width of 5, the returned rectangle would have an x-location of 1 with a width of 4.

Parameters
[in]rectA pointer to a FloatRect.
Returns
A FloatRect representing the difference between this rectangle and the receiving rectangle.

Definition at line 214 of file rect.cc.

References FloatRect(), height(), width(), x(), and y().

float pp::FloatRect::bottom ( ) const
inline

Getter function to get the upper-bound for the y-coordinates of the rectangle. Note that this coordinate value is one past the highest xy value of pixels in the rectangle. This loop will access all the pixels in a horizontal line in the rectangle: for (float y = rect.y(); y < rect.bottom(); ++y) {}

Returns
The value of y + height for this point.

Definition at line 620 of file rect.h.

References height(), and y().

Referenced by Contains(), Intersect(), Intersects(), SharesEdgeWith(), Subtract(), and Union().

FloatPoint pp::FloatRect::CenterPoint ( ) const

CenterPoint() determines the center of this rectangle.

Returns
A FloatPoint representing the center of this rectangle.

Definition at line 224 of file rect.cc.

References height(), width(), x(), and y().

bool pp::FloatRect::Contains ( float  point_x,
float  point_y 
) const

Contains() determines if the point identified by point_x and point_y falls inside this rectangle. The point (x, y) is inside the rectangle, but the point (x + width, y + height) is not.

Parameters
[in]point_xAn float value representing a x value.
[in]point_yAn float value representing a y value.
Returns
true if the point_x and point_y fall inside the rectangle.

Definition at line 142 of file rect.cc.

References bottom(), right(), x(), and y().

Referenced by Contains(), and Subtract().

bool pp::FloatRect::Contains ( const FloatPoint point) const
inline

Contains() determines if the specified point is contained by this rectangle.

Parameters
[in]pointA pointer to a Point representing a 2D coordinate.
Returns
true if the point_x and point_y fall inside the rectangle.

Definition at line 708 of file rect.h.

References Contains(), pp::FloatPoint::x(), and pp::FloatPoint::y().

bool pp::FloatRect::Contains ( const FloatRect rect) const

Contains() determines if this rectangle contains the specified rectangle.

Parameters
[in]rectA pointer to a FloatRect.
Returns
true if the rectangle fall inside this rectangle.

Definition at line 147 of file rect.cc.

References bottom(), right(), x(), and y().

FloatSize pp::FloatRect::Floatsize ( ) const
inline

Getter function for returning the FloatSize.

Returns
The size of the rectangle.

Definition at line 589 of file rect.h.

float pp::FloatRect::height ( ) const
inline

Getter function for returning the value of height.

Returns
The value of height for this FloatRect.

Definition at line 556 of file rect.h.

Referenced by AdjustToFit(), bottom(), CenterPoint(), Inset(), operator==(), and SharesEdgeWith().

void pp::FloatRect::Inset ( float  horizontal,
float  vertical 
)
inline

Inset() shrinks the rectangle by a horizontal and vertical distance on all sides.

Parameters
[in]horizontalAn float value representing a horizontal shrinking distance.
[in]verticalAn float value representing a vertical shrinking distance.

Definition at line 651 of file rect.h.

void pp::FloatRect::Inset ( float  left,
float  top,
float  right,
float  bottom 
)

Inset() shrinks the rectangle by the specified amount on each side.

Parameters
[in]leftAn float value representing a left shrinking distance.
[in]topAn float value representing a top shrinking distance.
[in]rightAn float value representing a right shrinking distance.
[in]bottomAn float value representing a bottom shrinking distance.

Definition at line 131 of file rect.cc.

References height(), Offset(), set_height(), set_width(), and width().

FloatRect pp::FloatRect::Intersect ( const FloatRect rect) const

Intersect() computes the intersection of this rectangle with the given rectangle.

Parameters
[in]rectA pointer to a FloatRect.
Returns
A FloatRect representing the intersection.

Definition at line 157 of file rect.cc.

References bottom(), FloatRect(), right(), x(), and y().

bool pp::FloatRect::Intersects ( const FloatRect rect) const

Intersects() determines if this rectangle intersects the specified rectangle.

Parameters
[in]rectA pointer to a FloatRect.
Returns
true if the rectangle intersects this rectangle.

Definition at line 152 of file rect.cc.

References bottom(), right(), x(), and y().

Referenced by Subtract().

bool pp::FloatRect::IsEmpty ( ) const
inline

IsEmpty() determines if the area of a rectangle is zero. Returns true if the area of the rectangle is zero.

Returns
true if the area of the rectangle is zero.

Definition at line 688 of file rect.h.

Referenced by Union().

void pp::FloatRect::Offset ( float  horizontal,
float  vertical 
)

Offset() moves the rectangle by a horizontal and vertical distance.

Parameters
[in]horizontalAn float value representing a horizontal move distance.
[in]verticalAn float value representing a vertical move distance.

Definition at line 137 of file rect.cc.

Referenced by Inset(), and Offset().

void pp::FloatRect::Offset ( const FloatPoint point)
inline

Offset() moves the rectangle by a horizontal and vertical distance.

Parameters
[in]pointA pointer to a FloatPoint representing the horizontal and vertical move distances.

Definition at line 680 of file rect.h.

References Offset(), pp::FloatPoint::x(), and pp::FloatPoint::y().

pp::FloatRect::operator PP_FloatRect ( ) const
inline

PP_FloatRect() allows implicit conversion of a FloatRect to a PP_FloatRect.

Returns
A Point.

Definition at line 485 of file rect.h.

FloatPoint pp::FloatRect::point ( ) const
inline

Getter function for returning the FloatPoint.

Returns
A FloatPoint.

Definition at line 574 of file rect.h.

const PP_FloatRect& pp::FloatRect::pp_float_rect ( ) const
inline

Getter function for returning the internal PP_FloatRect struct.

Returns
A const reference to the internal PP_FloatRect struct.

Definition at line 494 of file rect.h.

Referenced by pp::CompositorLayer::SetSourceRect().

PP_FloatRect& pp::FloatRect::pp_float_rect ( )
inline

Getter function for returning the internal PP_FloatRect struct.

Returns
A mutable reference to the PP_FloatRect struct.

Definition at line 502 of file rect.h.

float pp::FloatRect::right ( ) const
inline

Getter function to get the upper-bound for the x-coordinates of the rectangle. Note that this coordinate value is one past the highest x value of pixels in the rectangle. This loop will access all the pixels in a horizontal line in the rectangle: for (float x = rect.x(); x < rect.right(); ++x) {}

Returns
The value of x + width for this point.

Definition at line 609 of file rect.h.

References width(), and x().

Referenced by Contains(), Intersect(), Intersects(), SharesEdgeWith(), Subtract(), and Union().

void pp::FloatRect::set_height ( float  h)
inline

Setter function for setting the value of height.

Parameters
[in]hA new width height.

Definition at line 563 of file rect.h.

References PP_DCHECK.

Referenced by FloatRect(), Inset(), and SetRect().

void pp::FloatRect::set_point ( const FloatPoint origin)
inline

Setter function for setting the value of the FloatPoint.

Parameters
[in]originA FloatPoint representing the upper-left starting coordinate.

Definition at line 582 of file rect.h.

Referenced by FloatRect().

void pp::FloatRect::set_size ( const FloatSize s)
inline

Setter function for setting the FloatSize.

Parameters
[in]sA pointer to a FloatSize representing the height and width.

Definition at line 597 of file rect.h.

References pp::FloatSize::height(), and pp::FloatSize::width().

Referenced by FloatRect().

void pp::FloatRect::set_width ( float  w)
inline

Setter function for setting the value of width.

Parameters
[in]wA new width value.

Definition at line 545 of file rect.h.

References PP_DCHECK.

Referenced by FloatRect(), Inset(), and SetRect().

void pp::FloatRect::set_x ( float  in_x)
inline

Setter function for setting the value of x.

Parameters
[in]in_xA new x value.

Definition at line 517 of file rect.h.

Referenced by FloatRect(), and SetRect().

void pp::FloatRect::set_y ( float  in_y)
inline

Setter function for setting the value of y.

Parameters
[in]in_yA new y value.

Definition at line 531 of file rect.h.

Referenced by FloatRect(), and SetRect().

void pp::FloatRect::SetRect ( float  x,
float  y,
float  w,
float  h 
)
inline

Setter function for setting the value of the FloatRect.

Parameters
[in]xA new x value.
[in]yA new y value.
[in]wA new width value.
[in]hA new height value.

Definition at line 630 of file rect.h.

References set_height(), set_width(), set_x(), and set_y().

void pp::FloatRect::SetRect ( const PP_FloatRect &  rect)
inline

Setter function for setting the value of the FloatRect.

Parameters
[in]rectA pointer to a PP_FloatRect.

Definition at line 640 of file rect.h.

bool pp::FloatRect::SharesEdgeWith ( const FloatRect rect) const

SharesEdgeWith() determines if this rectangle shares an entire edge (same width or same height) with the given rectangle, and the rectangles do not overlap.

Parameters
[in]rectA pointer to a FloatRect.
Returns
true if this rectangle and supplied rectangle share an edge.

Definition at line 229 of file rect.cc.

References bottom(), height(), right(), width(), x(), and y().

FloatRect pp::FloatRect::Subtract ( const FloatRect rect) const

Subtract() computes the rectangle resulting from subtracting rect from this Rect. If rectdoes not intersect completely in either the x or y direction, then *this is returned. If rect contains this, then an empty Rect is returned.

Parameters
[in]rectA pointer to a FloatRect.
Returns
A FloatRect representing the subtraction.

Definition at line 184 of file rect.cc.

References bottom(), Contains(), FloatRect(), Intersects(), right(), x(), and y().

FloatRect pp::FloatRect::Union ( const FloatRect rect) const

Union() computes the union of this rectangle with the given rectangle. The union is the smallest rectangle containing both rectangles.

Parameters
[in]rectA pointer to a FloatRect.
Returns
A FloatRect representing the union.

Definition at line 169 of file rect.cc.

References bottom(), FloatRect(), IsEmpty(), right(), x(), and y().

float pp::FloatRect::width ( ) const
inline

Getter function for returning the value of width.

Returns
The value of width for this FloatRect.

Definition at line 538 of file rect.h.

Referenced by AdjustToFit(), CenterPoint(), Inset(), operator==(), right(), and SharesEdgeWith().

float pp::FloatRect::x ( ) const
inline

Getter function for returning the value of x.

Returns
The value of x for this FloatPoint.

Definition at line 510 of file rect.h.

Referenced by AdjustToFit(), CenterPoint(), Contains(), Intersect(), Intersects(), operator==(), right(), SharesEdgeWith(), Subtract(), and Union().

float pp::FloatRect::y ( ) const
inline

Getter function for returning the value of y.

Returns
The value of y for this FloatPoint.

Definition at line 524 of file rect.h.

Referenced by AdjustToFit(), bottom(), CenterPoint(), Contains(), Intersect(), Intersects(), operator==(), SharesEdgeWith(), Subtract(), and Union().


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