Rose
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
rose::Rectangle Class Reference

A composite of a Position and a Size. More...

#include <Types.h>

Inheritance diagram for rose::Rectangle:
Inheritance graph
[legend]
Collaboration diagram for rose::Rectangle:
Collaboration graph
[legend]

Public Member Functions

constexpr Rectangle (int X, int Y, int W, int H) noexcept
 
constexpr Rectangle (const Position< int > &p, const Size &s) noexcept
 
constexpr Rectangle (const Rectangle &p)=default
 
constexpr Rectangle (Rectangle &&p)=default
 
constexpr Rectangleoperator= (const Rectangle &p)=default
 
constexpr Rectangleoperator= (Rectangle &&p)=default
 
constexpr Rectangleoperator= (const Size &s)
 
constexpr Rectangleoperator= (const Position< int > &p)
 
constexpr Rectangle operator+ (const Position< int > &p) const noexcept
 Add a Position to a Rectangle.
 
constexpr Rectangle operator+ (const Size &s) const noexcept
 Add a Size to a Rectangle.
 
constexpr Rectangle operator- (const Size &s) const noexcept
 Subtract a Size from a Rectangle.
 
Position< int > position () const noexcept
 Get a Position from a Rectangle.
 
Size size () const noexcept
 Get a Size from a Rectangle.
 
std::pair< Position< int >, Position< int > > primeCorners () const noexcept
 Get the Positions of top-left and bottom-right corners defined by the Rectangle.
 
std::pair< Position< int >, Position< int > > crossCorners () const noexcept
 Get the Positions of the top-right and bottom-left corners defined by the Rectangle.
 
std::tuple< Position< int >, Position< int >, Position< int >, Position< int > > corners () const noexcept
 Get the Positions of all four corners defined by the Rectangle, top to bottom, left to right.
 
constexpr bool contains (Position< int > pos) const noexcept
 Determine if a Rectangle contains a Position.
 
constexpr bool noOverlap (const Rectangle &o) const noexcept
 Determine if there is no overlap between two Rectangle objects. More...
 
constexpr bool overlap (const Rectangle &o) const noexcept
 Determine if there is overlap between to Rectangle objects by inverting noOverlap(). More...
 
Rectangle intersection (const Rectangle &o) const
 
int & sizePri (Orientation o) noexcept
 
int & sizeSec (Orientation o) noexcept
 
int & posPri (Orientation o) noexcept
 
int & posSec (Orientation o) noexcept
 
constexpr int sizePri (Orientation o) const noexcept
 
constexpr int sizeSec (Orientation o) const noexcept
 
constexpr int posPri (Orientation o) const noexcept
 
constexpr int posSec (Orientation o) const noexcept
 
constexpr Rectangle (std::array< int, 4 > value) noexcept
 Constructor initialize to the value of an array.
 
constexpr Rectangle (int value=0) noexcept
 Default constructor initializes x and y to 0 or to a specified value.
 
constexpr Rectangle (int x, int y, int width, int height) noexcept
 Constructor initialize to descrete x, y, width, and height values.
 
constexpr Rectangle (const Rectangle &)=default
 Copy constructor.
 
constexpr Rectangle (Rectangle &&)=default
 Move constructor.
 
constexpr Rectangleoperator= (const Rectangle &)=default
 Copy assignment.
 
constexpr Rectangleoperator= (Rectangle &&)=default
 Move assignment.
 
constexpr Rectangle (const Position &pos, const Size &size)
 Constructor initialize to the value of a Position and Size.
 
constexpr Rectangle (const std::optional< Position > &pos, const std::optional< Size > &size)
 Constructor initialize to the value of std::optional Position and Size.
 
constexpr int & x ()
 Reference access to x.
 
constexpr int x () const noexcept
 Value access to x.
 
constexpr int & y ()
 Reference access to y.
 
constexpr int y () const noexcept
 Value access to y.
 
constexpr int & width ()
 Reference access to width.
 
constexpr int width () const noexcept
 Value access to width.
 
constexpr int & height ()
 Reference access to height.
 
constexpr int height () const noexcept
 Value access to height.
 
constexpr int & positionPrimary (Orientation orientation)
 
constexpr int & positionSecondary (Orientation orientation)
 
constexpr int & sizePrimary (Orientation orientation)
 
constexpr int & sizeSecondary (Orientation orientation)
 
constexpr Size getSize () const noexcept
 Get the Size of a Rectangle.
 
constexpr Position getPosition () const noexcept
 Get the Position of a Rectangle.
 
constexpr SDL_Rect toSdlRect () const noexcept
 
constexpr Rectangleoperator= (const Size &size)
 Assign a Size to a Rectangle.
 
constexpr Rectangleoperator= (const Position &position)
 Assign a Position to a Rectangle.
 
constexpr Rectangleoperator+= (const Position &deltaPos)
 Move a Rectangle by a delta Position.
 
constexpr Rectangle operator+ (const Position &deltaPos)
 Add a Position to a Rectangle.
 
constexpr Rectangle moveOrigin (const std::optional< Position > &deltaPos) const
 Move the origin of a Rectangle by an optional deltaPos and reduce the size of the rectangle by a corresponding amount.
 
constexpr bool contains (Position pos) const noexcept
 Determine if a Rectangle contains a Position.
 
constexpr bool noOverlap (const Rectangle &o) const noexcept
 Determine if there is no overlap between two Rectangle objects. More...
 
constexpr bool overlap (const Rectangle &o) const noexcept
 Determine if there is overlap between to Rectangle objects by inverting noOverlap(). More...
 
Rectangle intersection (const Rectangle &o) const
 

Public Attributes

int x {0}
 
int y {0}
 
int w {0}
 
int h {0}
 

Static Public Attributes

static Rectangle Zero {}
 
static const Rectangle Zero
 A rectangle with position and size of zero.
 

Detailed Description

A composite of a Position and a Size.

Describes area on the screen.

Position may be relative or absolute.

Member Function Documentation

◆ noOverlap() [1/2]

constexpr bool rose::Rectangle::noOverlap ( const Rectangle o) const
inlinenoexcept

Determine if there is no overlap between two Rectangle objects.

Parameters
oThe other Rectangle.
Returns
True if there is no overlap of this Rectangle and the other Rectangle.

◆ noOverlap() [2/2]

constexpr bool rose::Rectangle::noOverlap ( const Rectangle o) const
inlinenoexcept

Determine if there is no overlap between two Rectangle objects.

Parameters
oThe other Rectangle.
Returns
True if there is no overlap of this Rectangle and the other Rectangle.

◆ overlap() [1/2]

constexpr bool rose::Rectangle::overlap ( const Rectangle o) const
inlinenoexcept

Determine if there is overlap between to Rectangle objects by inverting noOverlap().

Parameters
oThe other Rectangle.
Returns
True if there is overlap of this Rectangle and the other Rectangle.

◆ overlap() [2/2]

constexpr bool rose::Rectangle::overlap ( const Rectangle o) const
inlinenoexcept

Determine if there is overlap between to Rectangle objects by inverting noOverlap().

Parameters
oThe other Rectangle.
Returns
True if there is overlap of this Rectangle and the other Rectangle.

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