Skip to content

Commit

Permalink
Added SDL_PointInRect().
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed May 27, 2014
1 parent ded970f commit b7f9044
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/SDL_rect.h
Expand Up @@ -43,6 +43,7 @@ extern "C" {
* \brief The structure that defines a point
*
* \sa SDL_EnclosePoints
* \sa SDL_PointInRect
*/
typedef struct SDL_Point
{
Expand All @@ -66,6 +67,15 @@ typedef struct SDL_Rect
int w, h;
} SDL_Rect;

/**
* \brief Returns true if point resides inside a rectangle.
*/
SDL_FORCE_INLINE SDL_bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r)
{
return ( (p->x >= r->x) && (p->x < (r->x + r->w)) &&
(p->y >= r->y) && (p->y < (r->y + r->h)) );
}

/**
* \brief Returns true if the rectangle has no area.
*/
Expand Down

0 comments on commit b7f9044

Please sign in to comment.