include/SDL_rect.h
changeset 8930 d000e6339d41
parent 8149 681eb46b8ac4
child 8943 a743e8b89e72
--- a/include/SDL_rect.h	Sat May 24 18:23:56 2014 -0400
+++ b/include/SDL_rect.h	Tue May 27 00:26:47 2014 -0400
@@ -43,6 +43,7 @@
  *  \brief  The structure that defines a point
  *
  *  \sa SDL_EnclosePoints
+ *  \sa SDL_PointInRect
  */
 typedef struct SDL_Point
 {
@@ -67,6 +68,15 @@
 } 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)