SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
SDL::Point Struct Reference

The structure that defines a point (using integers). More...

Inheritance diagram for SDL::Point:
[legend]

Public Member Functions

constexpr Point (const PointRaw &p={}) noexcept
 Wraps Point.
constexpr Point (int x, int y) noexcept
 Constructs from its fields.
constexpr Point (const FPointRaw &p)
 Wraps Point.
constexpr operator bool () const noexcept
 Check if valid.
constexpr int GetX () const noexcept
 Get x coordinate.
constexpr PointSetX (int newX) noexcept
 Set the x coordinate.
constexpr int GetY () const noexcept
 Get y coordinate.
constexpr PointSetY (int newY) noexcept
 Set the y coordinate.
bool InRect (const RectRaw &r) const
 Determine whether a point resides inside a rectangle.
constexpr Point operator- () const
 Get point's memberwise negation.
constexpr Point operator+ (const Point &other) const
 Get point's memberwise addition with another point.
constexpr Point operator- (const Point &other) const
 Get point's memberwise subtraction with another point.
constexpr Point operator/ (int value) const
 Get point's memberwise division by an integer.
constexpr FPoint operator/ (float value) const
 Get point's memberwise division by an integer.
constexpr Point operator/ (const Point &other) const
 Get point's memberwise division by another point.
constexpr Point operator% (int value) const
 Get point's memberwise remainder from division by an integer.
constexpr Point operator% (const Point &other) const
 Get point's memberwise remainder from division by another point.
constexpr Point operator* (int value) const
 Get point's memberwise multiplication by an integer.
constexpr FPoint operator* (float value) const
 Get point's memberwise multiplication by an integer.
constexpr Point operator* (const Point &other) const
 Get point's memberwise multiplication by another point.
constexpr Pointoperator+= (const Point &other)
 Memberwise add another point.
constexpr Pointoperator-= (const Point &other)
 Memberwise subtract another point.
constexpr Pointoperator/= (int value)
 Memberwise divide by an integer.
constexpr Pointoperator/= (const Point &other)
 Memberwise divide by another point.
constexpr Pointoperator%= (int value)
 Memberwise remainder from division by an integer.
constexpr Pointoperator%= (const Point &other)
 Memberwise remainder from division by another point.
constexpr Pointoperator*= (int value)
 Memberwise multiply by an integer.
constexpr Pointoperator*= (const Point &other)
 Memberwise multiply by another point.
constexpr Point GetClamped (const Rect &rect) const
 Get a point with coordinates modified so it fits into a given rect.
constexpr PointClamp (const Rect &rect)
 Clamp point coordinates to make it fit into a given rect.
constexpr Point GetWrapped (const Rect &rect) const
 Get a point wrapped within a specified rect.
constexpr PointWrap (const Rect &rect)
 Wrap point coordinates within a specified rect.
constexpr operator FPoint () const
 Converts to FPoint.

Detailed Description

The structure that defines a point (using integers).

Inspired by https://github.com/libSDL2pp/libSDL2pp/blob/master/SDL2pp/Point.hh

Since
This struct is available since SDL 3.2.0.
Category:
Wrap extending struct
See also
Rect.GetEnclosingPoints
Point.InRect

Constructor & Destructor Documentation

◆ Point() [1/3]

SDL::Point::Point ( const PointRaw & p = {})
inlineconstexprnoexcept

Wraps Point.

Parameters
pthe value to be wrapped

◆ Point() [2/3]

SDL::Point::Point ( int x,
int y )
inlineconstexprnoexcept

Constructs from its fields.

Parameters
xthe value for x.
ythe value for y.

◆ Point() [3/3]

SDL::Point::Point ( const FPointRaw & p)
inlineexplicitconstexpr

Wraps Point.

Parameters
pthe value to be wrapped

Member Function Documentation

◆ Clamp()

Point & SDL::Point::Clamp ( const Rect & rect)
constexpr

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

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

◆ GetClamped()

Point SDL::Point::GetClamped ( const Rect & rect) const
constexpr

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

Parameters
[in]rectRectangle to clamp with
Returns
Clamped point

◆ GetWrapped()

Point SDL::Point::GetWrapped ( const Rect & rect) const
constexpr

Get a point wrapped within a specified rect.

Parameters
[in]rectRectangle to wrap with
Returns
Wrapped point

◆ GetX()

int SDL::Point::GetX ( ) const
inlineconstexprnoexcept

Get x coordinate.

Returns
x coordinate

◆ GetY()

int SDL::Point::GetY ( ) const
inlineconstexprnoexcept

Get y coordinate.

Returns
y coordinate

◆ operator bool()

SDL::Point::operator bool ( ) const
inlineexplicitconstexprnoexcept

Check if valid.

Returns
True if valid state, false otherwise.

◆ operator FPoint()

SDL::Point::operator FPoint ( ) const
constexpr

Converts to FPoint.

Returns
FPoint

◆ operator%() [1/2]

Point SDL::Point::operator% ( const Point & other) const
inlineconstexpr

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%() [2/2]

Point SDL::Point::operator% ( int value) const
inlineconstexpr

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%=() [1/2]

Point & SDL::Point::operator%= ( const Point & other)
inlineconstexpr

Memberwise remainder from division by another point.

Parameters
[in]otherDivisor
Returns
Reference to self

◆ operator%=() [2/2]

Point & SDL::Point::operator%= ( int value)
inlineconstexpr

Memberwise remainder from division by an integer.

Parameters
[in]valueDivisor
Returns
Reference to self

◆ operator*() [1/3]

Point SDL::Point::operator* ( const Point & other) const
inlineconstexpr

Get point's memberwise multiplication by another point.

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

◆ operator*() [2/3]

FPoint SDL::Point::operator* ( float value) const
constexpr

Get point's memberwise multiplication by an integer.

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

◆ operator*() [3/3]

Point SDL::Point::operator* ( int value) const
inlineconstexpr

Get point's memberwise multiplication by an integer.

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

◆ operator*=() [1/2]

Point & SDL::Point::operator*= ( const Point & other)
inlineconstexpr

Memberwise multiply by another point.

Parameters
[in]otherMultiplier
Returns
Reference to self

◆ operator*=() [2/2]

Point & SDL::Point::operator*= ( int value)
inlineconstexpr

Memberwise multiply by an integer.

Parameters
[in]valueMultiplier
Returns
Reference to self

◆ operator+()

Point SDL::Point::operator+ ( const Point & other) const
inlineconstexpr

Get point's memberwise addition with another point.

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

◆ operator+=()

Point & SDL::Point::operator+= ( const Point & other)
inlineconstexpr

Memberwise add another point.

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

◆ operator-() [1/2]

Point SDL::Point::operator- ( ) const
inlineconstexpr

Get point's memberwise negation.

Returns
New Point representing memberwise negation

◆ operator-() [2/2]

Point SDL::Point::operator- ( const Point & other) const
inlineconstexpr

Get point's memberwise subtraction with another point.

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

◆ operator-=()

Point & SDL::Point::operator-= ( const Point & other)
inlineconstexpr

Memberwise subtract another point.

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

◆ operator/() [1/3]

Point SDL::Point::operator/ ( const Point & other) const
inlineconstexpr

Get point's memberwise division by another point.

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

◆ operator/() [2/3]

FPoint SDL::Point::operator/ ( float value) const
constexpr

Get point's memberwise division by an integer.

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

◆ operator/() [3/3]

Point SDL::Point::operator/ ( int value) const
inlineconstexpr

Get point's memberwise division by an integer.

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

◆ operator/=() [1/2]

Point & SDL::Point::operator/= ( const Point & other)
inlineconstexpr

Memberwise divide by another point.

Parameters
[in]otherDivisor
Returns
Reference to self

◆ operator/=() [2/2]

Point & SDL::Point::operator/= ( int value)
inlineconstexpr

Memberwise divide by an integer.

Parameters
[in]valueDivisor
Returns
Reference to self

◆ SetX()

Point & SDL::Point::SetX ( int newX)
inlineconstexprnoexcept

Set the x coordinate.

Parameters
newXthe new x coordinate.
Returns
Reference to self.

◆ SetY()

Point & SDL::Point::SetY ( int newY)
inlineconstexprnoexcept

Set the y coordinate.

Parameters
newYthe new y coordinate.
Returns
Reference to self.

◆ Wrap()

Point & SDL::Point::Wrap ( const Rect & rect)
constexpr

Wrap point coordinates within a specified rect.

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

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