SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Classes | Functions
Rectangle Functions

Some helper functions for managing rectangles and 2D points, in both integer and floating point versions. More...

Classes

struct  SDL::Point
 The structure that defines a point (using integers) More...
 
struct  SDL::FPoint
 The structure that defines a point (using floating point values). More...
 
struct  SDL::Rect
 A rectangle, with the origin at the upper left (using integers). More...
 
struct  SDL::FRect
 A rectangle, with the origin at the upper left (using floats). More...
 

Functions

constexpr bool SDL::Point::IsInRect (const Rect &r) const
 Determine whether a point resides inside a rectangle.
 
constexpr bool SDL::FPoint::IsInRect (const FRect &r) const
 Determine whether a point resides inside a floating point rectangle.
 

Detailed Description

Function Documentation

◆ IsInRect() [1/2]

constexpr bool SDL::FPoint::IsInRect ( const FRect r) const
constexpr

A point is considered part of a rectangle if both p and r are not NULL, and p's x and y coordinates are >= to the rectangle's top left corner, and <= the rectangle's x+w and y+h. So a 1x1 rectangle considers point (0,0) and (0,1) as "inside" and (0,2) as not.

Note that this is a forced-inline function in a header, and not a public API function available in the SDL library (which is to say, the code is embedded in the calling program and the linker and dynamic loader will not be able to find this function inside SDL itself).

Parameters
rthe rectangle to test.
Returns
true if this is contained by r, false otherwise.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.

◆ IsInRect() [2/2]

constexpr bool SDL::Point::IsInRect ( const Rect r) const
constexpr

A point is considered part of a rectangle if both p and r are not NULL, and p's x and y coordinates are >= to the rectangle's top left corner, and < the rectangle's x+w and y+h. So a 1x1 rectangle considers point (0,0) as "inside" and (0,1) as not.

Note that this is a forced-inline function in a header, and not a public API function available in the SDL library (which is to say, the code is embedded in the calling program and the linker and dynamic loader will not be able to find this function inside SDL itself).

Parameters
rthe rectangle to test.
Returns
true if this is contained by r, false otherwise.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.