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 (int v) 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 Pointoperator+= (const Point &other)
 Memberwise add another point.
constexpr Pointoperator-= (const Point &other)
 Memberwise subtract another point.
constexpr Pointoperator/= (const Point &other)
 Memberwise divide by another point.
constexpr Pointoperator%= (const Point &other)
 Memberwise remainder from division by another point.
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
GetRectEnclosingPoints
PointInRect

Constructor & Destructor Documentation

◆ Point() [1/4]

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

Wraps Point.

Parameters
pthe value to be wrapped

◆ Point() [2/4]

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

Constructs from its fields.

Parameters
xthe value for x.
ythe value for y.

◆ Point() [3/4]

SDL::Point::Point ( int v)
inlineconstexprnoexcept

Constructs from its fields.

Parameters
vthe value for x and y.

◆ Point() [4/4]

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%=()

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

Memberwise remainder from division by another point.

Parameters
[in]otherDivisor
Returns
Reference to self

◆ operator*=()

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

Memberwise multiply by another point.

Parameters
[in]otherMultiplier
Returns
Reference to self

◆ 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-()

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

Get point's memberwise negation.

Returns
New Point representing memberwise negation

◆ 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/=()

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

Memberwise divide by another point.

Parameters
[in]otherDivisor
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: