Commit b7f90442df7ff21867e0e50417cf1ab0b3bedb1c

Ryan C. Gordon 2014-05-27T00:26:47

Added SDL_PointInRect().

diff --git a/include/SDL_rect.h b/include/SDL_rect.h
index 0a95a33..e170a01 100644
--- a/include/SDL_rect.h
+++ b/include/SDL_rect.h
@@ -43,6 +43,7 @@ extern "C" {
  *  \brief  The structure that defines a point
  *
  *  \sa SDL_EnclosePoints
+ *  \sa SDL_PointInRect
  */
 typedef struct SDL_Point
 {
@@ -67,6 +68,15 @@ typedef struct SDL_Rect
 } 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.
  */
 SDL_FORCE_INLINE SDL_bool SDL_RectEmpty(const SDL_Rect *r)