libSDL2pp  0.16.0
C++11 bindings/wrapper for SDL2
Public Member Functions | List of all members
SDL2pp::Point Class Reference

2D point More...

#include <SDL2pp/Point.hh>

Inheritance diagram for SDL2pp::Point:

Public Member Functions

constexpr Point ()
 Default constructor. More...
 
constexpr Point (const SDL_Point &point)
 Construct a point from existing SDL_Point. More...
 
constexpr Point (int x, int y)
 Construct the point from given coordinates. More...
 
 Point (const Point &) noexcept=default
 Copy constructor.
 
 Point (Point &&) noexcept=default
 Move constructor.
 
Pointoperator= (const Point &) noexcept=default
 Assignment operator. More...
 
Pointoperator= (Point &&) noexcept=default
 Move assignment operator. More...
 
constexpr int GetX () const
 Get X coordinate of the point. More...
 
PointSetX (int nx)
 Set X coordinate of the point. More...
 
constexpr int GetY () const
 Get Y coordinate of the point. More...
 
PointSetY (int ny)
 Set Y coordinate of the point. More...
 
constexpr Point operator- () const
 Get point's memberwise negation. More...
 
constexpr Point operator+ (const Point &other) const
 Get point's memberwise addition with another point. More...
 
constexpr Point operator- (const Point &other) const
 Get point's memberwise subtraction with another point. More...
 
constexpr Point operator/ (int value) const
 Get point's memberwise division by an integer. More...
 
constexpr Point operator/ (const Point &other) const
 Get point's memberwise division by another point. More...
 
constexpr Point operator% (int value) const
 Get point's memberwise remainder from division by an integer. More...
 
constexpr Point operator% (const Point &other) const
 Get point's memberwise remainder from division by another point. More...
 
constexpr Point operator* (int value) const
 Get point's memberwise multiplication by an integer. More...
 
constexpr Point operator* (const Point &other) const
 Get point's memberwise multiplication by anoter point. More...
 
Pointoperator+= (const Point &other)
 Memberwise add another point. More...
 
Pointoperator-= (const Point &other)
 Memberwise subtract another point. More...
 
Pointoperator/= (int value)
 Memberwise divide by an integer. More...
 
Pointoperator/= (const Point &other)
 
Pointoperator%= (int value)
 Memberwise remainder from division by an integer. More...
 
Pointoperator%= (const Point &other)
 Memberwise remainder from division by another point. More...
 
Pointoperator*= (int value)
 Memberwise multiply by an integer. More...
 
Pointoperator*= (const Point &other)
 Memberwise multiply by another point. More...
 
Point GetClamped (const Rect &rect) const
 Get a point with coordinates modified so it fits into a given rect. More...
 
PointClamp (const Rect &rect)
 Clamp point coordinates to make it fit into a given rect. More...
 
Point GetWrapped (const Rect &rect) const
 Get a point wrapped within a specified rect. More...
 
PointWrap (const Rect &rect)
 Wrap point coordinates within a spedified rect. More...
 

Detailed Description

2D point

This class is public-derived from SDL_Point structure, may generally used as it if passed via pointer or reference. It also supports direct access to x and y members.

See also
http://wiki.libsdl.org/SDL_Point

Constructor & Destructor Documentation

◆ Point() [1/3]

constexpr SDL2pp::Point::Point ( )
inline

Default constructor.

Creates a Point(0, 0)

◆ Point() [2/3]

constexpr SDL2pp::Point::Point ( const SDL_Point &  point)
inline

Construct a point from existing SDL_Point.

Parameters
[in]pointExisting SDL_Point

◆ Point() [3/3]

constexpr SDL2pp::Point::Point ( int  x,
int  y 
)
inline

Construct the point from given coordinates.

Parameters
[in]xX coordinate
[in]yY coordinate

Member Function Documentation

◆ Clamp()

Point & SDL2pp::Point::Clamp ( const Rect rect)

Clamp point coordinates to make it fit into a given rect.

Parameters
[in]rectRectangle to clamp with
Returns
Reference to self

◆ GetClamped()

Point SDL2pp::Point::GetClamped ( const Rect rect) const

Get a point with coordinates modified so it fits into a given rect.

Parameters
[in]rectRectangle to clamp with
Returns
Clamped point

◆ GetWrapped()

Point SDL2pp::Point::GetWrapped ( const Rect rect) const

Get a point wrapped within a specified rect.

Parameters
[in]rectRectangle to wrap with
Returns
Wrapped point

◆ GetX()

constexpr int SDL2pp::Point::GetX ( ) const
inline

Get X coordinate of the point.

Returns
X coordinate of the point

◆ GetY()

constexpr int SDL2pp::Point::GetY ( ) const
inline

Get Y coordinate of the point.

Returns
Y coordinate of the point

◆ operator%() [1/2]

constexpr Point SDL2pp::Point::operator% ( int  value) const
inline

Get point's memberwise remainder from division by an integer.

Parameters
[in]valueDivisor
Returns
New Point representing memberwise remainder from division by an integer

◆ operator%() [2/2]

constexpr Point SDL2pp::Point::operator% ( const Point other) const
inline

Get point's memberwise remainder from division by another point.

Parameters
[in]otherDivisor
Returns
New Point representing memberwise remainder from division by another point

◆ operator%=() [1/2]

Point& SDL2pp::Point::operator%= ( int  value)
inline

Memberwise remainder from division by an integer.

Parameters
[in]valueDivisor
Returns
Reference to self

◆ operator%=() [2/2]

Point& SDL2pp::Point::operator%= ( const Point other)
inline

Memberwise remainder from division by another point.

Parameters
[in]otherDivisor
Returns
Reference to self

◆ operator*() [1/2]

constexpr Point SDL2pp::Point::operator* ( int  value) const
inline

Get point's memberwise multiplication by an integer.

Parameters
[in]valueMultiplier
Returns
New Point representing memberwise multiplication of point by an integer

◆ operator*() [2/2]

constexpr Point SDL2pp::Point::operator* ( const Point other) const
inline

Get point's memberwise multiplication by anoter point.

Parameters
[in]otherMultiplier
Returns
New Point representing memberwise multiplication of point by another point

◆ operator*=() [1/2]

Point& SDL2pp::Point::operator*= ( int  value)
inline

Memberwise multiply by an integer.

Parameters
[in]valueMultiplier
Returns
Reference to self

◆ operator*=() [2/2]

Point& SDL2pp::Point::operator*= ( const Point other)
inline

Memberwise multiply by another point.

Parameters
[in]otherMultiplier
Returns
Reference to self

◆ operator+()

constexpr Point SDL2pp::Point::operator+ ( const Point other) const
inline

Get point's memberwise addition with another point.

Parameters
[in]otherPoint to add
Returns
New Point representing memberwise addition with another point

◆ operator+=()

Point& SDL2pp::Point::operator+= ( const Point other)
inline

Memberwise add another point.

Parameters
[in]otherPoint to add to the current one
Returns
Reference to self

◆ operator-() [1/2]

constexpr Point SDL2pp::Point::operator- ( ) const
inline

Get point's memberwise negation.

Returns
New Point representing memberwise negation

◆ operator-() [2/2]

constexpr Point SDL2pp::Point::operator- ( const Point other) const
inline

Get point's memberwise subtraction with another point.

Parameters
[in]otherPoint to subtract
Returns
New Point representing memberwise subtraction of another point

◆ operator-=()

Point& SDL2pp::Point::operator-= ( const Point other)
inline

Memberwise subtract another point.

Parameters
[in]otherPoint to subtract from the current one
Returns
Reference to self

◆ operator/() [1/2]

constexpr Point SDL2pp::Point::operator/ ( int  value) const
inline

Get point's memberwise division by an integer.

Parameters
[in]valueDivisor
Returns
New Point representing memberwise division of point by an integer

◆ operator/() [2/2]

constexpr Point SDL2pp::Point::operator/ ( const Point other) const
inline

Get point's memberwise division by another point.

Parameters
[in]otherDivisor
Returns
New Point representing memberwise division of point by another point

◆ operator/=() [1/2]

Point& SDL2pp::Point::operator/= ( int  value)
inline

Memberwise divide by an integer.

Parameters
[in]valueDivisor
Returns
Reference to self

◆ operator/=() [2/2]

Point& SDL2pp::Point::operator/= ( const Point other)
inline

nbrief Memberwise divide by another point

Parameters
[in]otherDivisor
Returns
Reference to self

◆ operator=() [1/2]

Point& SDL2pp::Point::operator= ( const Point )
defaultnoexcept

Assignment operator.

Returns
Reference to self

◆ operator=() [2/2]

Point& SDL2pp::Point::operator= ( Point &&  )
defaultnoexcept

Move assignment operator.

Returns
Reference to self

◆ SetX()

Point& SDL2pp::Point::SetX ( int  nx)
inline

Set X coordinate of the point.

Parameters
[in]nxNew X coordinate value
Returns
Reference to self

◆ SetY()

Point& SDL2pp::Point::SetY ( int  ny)
inline

Set Y coordinate of the point.

Parameters
[in]nyNew Y coordinate value
Returns
Reference to self

◆ Wrap()

Point & SDL2pp::Point::Wrap ( const Rect rect)

Wrap point coordinates within a spedified rect.

Parameters
[in]rectRectangle to wrap with
Returns
Reference to self

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