ezgl  1.0.1
An Easy Graphics & GUI Library
Public Member Functions | Public Attributes | Friends | List of all members
ezgl::rectangle Class Reference

Represents a rectangle as two diagonally opposite points. More...

#include <rectangle.hpp>

Public Member Functions

 rectangle ()
 Default constructor: Create a zero-sized rectangle at {0,0}.
 
 rectangle (point2d origin_pt, point2d top_right_pt)
 Create a rectangle from two diagonally opposite points.
 
 rectangle (point2d origin_pt, double rec_width, double rec_height)
 Create a rectangle with a given width and height.
 
double left () const
 The minimum x-coordinate.
 
double right () const
 The maximum x-coordinate.
 
double bottom () const
 The minimum y-coordinate.
 
double top () const
 The maximum y-coordinate.
 
point2d bottom_left () const
 The minimum x-coordinate and the minimum y-coordinate.
 
point2d top_left () const
 The minimum x-coordinate and the maximum y-coordinate.
 
point2d bottom_right () const
 The maximum x-coordinate and the minimum y-coordinate.
 
point2d top_right () const
 The maximum x-coordinate and the maximum y-coordinate.
 
bool contains (double x, double y) const
 Test if the x and y values are within the rectangle.
 
bool contains (point2d point) const
 Test if the x and y values are within the rectangle.
 
double width () const
 The width of the rectangle.
 
double height () const
 The height of the rectangle.
 
double area () const
 The area of the rectangle.
 
double center_x () const
 The center of the rectangle in the x plane.
 
double center_y () const
 The center of the rectangle in the y plane.
 
point2d center () const
 The center of the recangle.
 
bool operator== (const rectangle &rhs) const
 Test for equality.
 
bool operator!= (const rectangle &rhs) const
 Test for inequality.
 

Public Attributes

point2d m_first
 The first point of the rectangle.
 
point2d m_second
 The second point of the rectangle.
 

Friends

rectangleoperator+= (rectangle &lhs, point2d const &rhs)
 translate the rectangle by positive offsets.
 
rectangleoperator-= (rectangle &lhs, point2d const &rhs)
 translate the rectangle by negative offsets.
 
rectangle operator- (rectangle &lhs, point2d const &rhs)
 Create a new rectangle that is translated (negative offsets).
 
rectangle operator+ (rectangle &lhs, point2d const &rhs)
 Create a new rectangle that is translated (positive offsets).
 

Detailed Description

Represents a rectangle as two diagonally opposite points.


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