My Project
Loading...
Searching...
No Matches
SDL_rect.h File Reference
#include "SDL_stdinc.h"
#include "SDL_error.h"
#include "SDL_pixels.h"
#include "SDL_rwops.h"
#include "begin_code.h"
#include "close_code.h"

Go to the source code of this file.

Data Structures

struct  SDL_Point
 
struct  SDL_FPoint
 
struct  SDL_Rect
 
struct  SDL_FRect
 

Typedefs

typedef struct SDL_Point SDL_Point
 
typedef struct SDL_FPoint SDL_FPoint
 
typedef struct SDL_Rect SDL_Rect
 
typedef struct SDL_FRect SDL_FRect
 

Functions

SDL_FORCE_INLINE SDL_bool SDL_PointInRect (const SDL_Point *p, const SDL_Rect *r)
 
SDL_FORCE_INLINE SDL_bool SDL_RectEmpty (const SDL_Rect *r)
 
SDL_FORCE_INLINE SDL_bool SDL_RectEquals (const SDL_Rect *a, const SDL_Rect *b)
 
DECLSPEC SDL_bool SDLCALL SDL_HasIntersection (const SDL_Rect *A, const SDL_Rect *B)
 
DECLSPEC SDL_bool SDLCALL SDL_IntersectRect (const SDL_Rect *A, const SDL_Rect *B, SDL_Rect *result)
 
DECLSPEC void SDLCALL SDL_UnionRect (const SDL_Rect *A, const SDL_Rect *B, SDL_Rect *result)
 
DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints (const SDL_Point *points, int count, const SDL_Rect *clip, SDL_Rect *result)
 
DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine (const SDL_Rect *rect, int *X1, int *Y1, int *X2, int *Y2)
 
SDL_FORCE_INLINE SDL_bool SDL_PointInFRect (const SDL_FPoint *p, const SDL_FRect *r)
 
SDL_FORCE_INLINE SDL_bool SDL_FRectEmpty (const SDL_FRect *r)
 
SDL_FORCE_INLINE SDL_bool SDL_FRectEqualsEpsilon (const SDL_FRect *a, const SDL_FRect *b, const float epsilon)
 
SDL_FORCE_INLINE SDL_bool SDL_FRectEquals (const SDL_FRect *a, const SDL_FRect *b)
 
DECLSPEC SDL_bool SDLCALL SDL_HasIntersectionF (const SDL_FRect *A, const SDL_FRect *B)
 
DECLSPEC SDL_bool SDLCALL SDL_IntersectFRect (const SDL_FRect *A, const SDL_FRect *B, SDL_FRect *result)
 
DECLSPEC void SDLCALL SDL_UnionFRect (const SDL_FRect *A, const SDL_FRect *B, SDL_FRect *result)
 
DECLSPEC SDL_bool SDLCALL SDL_EncloseFPoints (const SDL_FPoint *points, int count, const SDL_FRect *clip, SDL_FRect *result)
 
DECLSPEC SDL_bool SDLCALL SDL_IntersectFRectAndLine (const SDL_FRect *rect, float *X1, float *Y1, float *X2, float *Y2)
 

Detailed Description

Header file for SDL_rect definition and management functions.

Typedef Documentation

◆ SDL_FPoint

typedef struct SDL_FPoint SDL_FPoint

The structure that defines a point (floating point)

See also
SDL_EncloseFPoints
SDL_PointInFRect

◆ SDL_FRect

◆ SDL_Point

typedef struct SDL_Point SDL_Point

The structure that defines a point (integer)

See also
SDL_EnclosePoints
SDL_PointInRect

◆ SDL_Rect

typedef struct SDL_Rect SDL_Rect

Function Documentation

◆ SDL_EncloseFPoints()

DECLSPEC SDL_bool SDLCALL SDL_EncloseFPoints ( const SDL_FPoint points,
int  count,
const SDL_FRect clip,
SDL_FRect result 
)

Calculate a minimal rectangle enclosing a set of points with float precision.

If clip is not NULL then only points inside of the clipping rectangle are considered.

Parameters
pointsan array of SDL_FPoint structures representing points to be enclosed
countthe number of structures in the points array
clipan SDL_FRect used for clipping or NULL to enclose all points
resultan SDL_FRect structure filled in with the minimal enclosing rectangle
Returns
SDL_TRUE if any points were enclosed or SDL_FALSE if all the points were outside of the clipping rectangle.
Since
This function is available since SDL 2.0.22.

◆ SDL_EnclosePoints()

DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints ( const SDL_Point points,
int  count,
const SDL_Rect clip,
SDL_Rect result 
)

Calculate a minimal rectangle enclosing a set of points.

If clip is not NULL then only points inside of the clipping rectangle are considered.

Parameters
pointsan array of SDL_Point structures representing points to be enclosed
countthe number of structures in the points array
clipan SDL_Rect used for clipping or NULL to enclose all points
resultan SDL_Rect structure filled in with the minimal enclosing rectangle
Returns
SDL_TRUE if any points were enclosed or SDL_FALSE if all the points were outside of the clipping rectangle.
Since
This function is available since SDL 2.0.0.

◆ SDL_FRectEmpty()

SDL_FORCE_INLINE SDL_bool SDL_FRectEmpty ( const SDL_FRect r)

Returns true if the rectangle has no area.

◆ SDL_FRectEquals()

SDL_FORCE_INLINE SDL_bool SDL_FRectEquals ( const SDL_FRect a,
const SDL_FRect b 
)

Returns true if the two rectangles are equal, using a default epsilon.

Since
This function is available since SDL 2.0.22.

◆ SDL_FRectEqualsEpsilon()

SDL_FORCE_INLINE SDL_bool SDL_FRectEqualsEpsilon ( const SDL_FRect a,
const SDL_FRect b,
const float  epsilon 
)

Returns true if the two rectangles are equal, within some given epsilon.

Since
This function is available since SDL 2.0.22.

◆ SDL_HasIntersection()

DECLSPEC SDL_bool SDLCALL SDL_HasIntersection ( const SDL_Rect A,
const SDL_Rect B 
)

Determine whether two rectangles intersect.

If either pointer is NULL the function will return SDL_FALSE.

Parameters
Aan SDL_Rect structure representing the first rectangle
Ban SDL_Rect structure representing the second rectangle
Returns
SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
Since
This function is available since SDL 2.0.0.
See also
SDL_IntersectRect

◆ SDL_HasIntersectionF()

DECLSPEC SDL_bool SDLCALL SDL_HasIntersectionF ( const SDL_FRect A,
const SDL_FRect B 
)

Determine whether two rectangles intersect with float precision.

If either pointer is NULL the function will return SDL_FALSE.

Parameters
Aan SDL_FRect structure representing the first rectangle
Ban SDL_FRect structure representing the second rectangle
Returns
SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
Since
This function is available since SDL 2.0.22.
See also
SDL_IntersectRect

◆ SDL_IntersectFRect()

DECLSPEC SDL_bool SDLCALL SDL_IntersectFRect ( const SDL_FRect A,
const SDL_FRect B,
SDL_FRect result 
)

Calculate the intersection of two rectangles with float precision.

If result is NULL then this function will return SDL_FALSE.

Parameters
Aan SDL_FRect structure representing the first rectangle
Ban SDL_FRect structure representing the second rectangle
resultan SDL_FRect structure filled in with the intersection of rectangles A and B
Returns
SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
Since
This function is available since SDL 2.0.22.
See also
SDL_HasIntersectionF

◆ SDL_IntersectFRectAndLine()

DECLSPEC SDL_bool SDLCALL SDL_IntersectFRectAndLine ( const SDL_FRect rect,
float *  X1,
float *  Y1,
float *  X2,
float *  Y2 
)

Calculate the intersection of a rectangle and line segment with float precision.

This function is used to clip a line segment to a rectangle. A line segment contained entirely within the rectangle or that does not intersect will remain unchanged. A line segment that crosses the rectangle at either or both ends will be clipped to the boundary of the rectangle and the new coordinates saved in X1, Y1, X2, and/or Y2 as necessary.

Parameters
rectan SDL_FRect structure representing the rectangle to intersect
X1a pointer to the starting X-coordinate of the line
Y1a pointer to the starting Y-coordinate of the line
X2a pointer to the ending X-coordinate of the line
Y2a pointer to the ending Y-coordinate of the line
Returns
SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
Since
This function is available since SDL 2.0.22.

◆ SDL_IntersectRect()

DECLSPEC SDL_bool SDLCALL SDL_IntersectRect ( const SDL_Rect A,
const SDL_Rect B,
SDL_Rect result 
)

Calculate the intersection of two rectangles.

If result is NULL then this function will return SDL_FALSE.

Parameters
Aan SDL_Rect structure representing the first rectangle
Ban SDL_Rect structure representing the second rectangle
resultan SDL_Rect structure filled in with the intersection of rectangles A and B
Returns
SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
Since
This function is available since SDL 2.0.0.
See also
SDL_HasIntersection

◆ SDL_IntersectRectAndLine()

DECLSPEC SDL_bool SDLCALL SDL_IntersectRectAndLine ( const SDL_Rect rect,
int *  X1,
int *  Y1,
int *  X2,
int *  Y2 
)

Calculate the intersection of a rectangle and line segment.

This function is used to clip a line segment to a rectangle. A line segment contained entirely within the rectangle or that does not intersect will remain unchanged. A line segment that crosses the rectangle at either or both ends will be clipped to the boundary of the rectangle and the new coordinates saved in X1, Y1, X2, and/or Y2 as necessary.

Parameters
rectan SDL_Rect structure representing the rectangle to intersect
X1a pointer to the starting X-coordinate of the line
Y1a pointer to the starting Y-coordinate of the line
X2a pointer to the ending X-coordinate of the line
Y2a pointer to the ending Y-coordinate of the line
Returns
SDL_TRUE if there is an intersection, SDL_FALSE otherwise.
Since
This function is available since SDL 2.0.0.

◆ SDL_PointInFRect()

SDL_FORCE_INLINE SDL_bool SDL_PointInFRect ( const SDL_FPoint p,
const SDL_FRect r 
)

Returns true if point resides inside a rectangle.

◆ SDL_PointInRect()

SDL_FORCE_INLINE SDL_bool SDL_PointInRect ( const SDL_Point p,
const SDL_Rect r 
)

Returns true if point resides inside a rectangle.

◆ SDL_RectEmpty()

SDL_FORCE_INLINE SDL_bool SDL_RectEmpty ( const SDL_Rect r)

Returns true if the rectangle has no area.

◆ SDL_RectEquals()

SDL_FORCE_INLINE SDL_bool SDL_RectEquals ( const SDL_Rect a,
const SDL_Rect b 
)

Returns true if the two rectangles are equal.

◆ SDL_UnionFRect()

DECLSPEC void SDLCALL SDL_UnionFRect ( const SDL_FRect A,
const SDL_FRect B,
SDL_FRect result 
)

Calculate the union of two rectangles with float precision.

Parameters
Aan SDL_FRect structure representing the first rectangle
Ban SDL_FRect structure representing the second rectangle
resultan SDL_FRect structure filled in with the union of rectangles A and B
Since
This function is available since SDL 2.0.22.

◆ SDL_UnionRect()

DECLSPEC void SDLCALL SDL_UnionRect ( const SDL_Rect A,
const SDL_Rect B,
SDL_Rect result 
)

Calculate the union of two rectangles.

Parameters
Aan SDL_Rect structure representing the first rectangle
Ban SDL_Rect structure representing the second rectangle
resultan SDL_Rect structure filled in with the union of rectangles A and B
Since
This function is available since SDL 2.0.0.