Added SDL_PointInRect().
authorRyan C. Gordon <icculus@icculus.org>
Tue, 27 May 2014 00:26:47 -0400
changeset 8930 d000e6339d41
parent 8929 7b459b49fa92
child 8931 44d8a2f4b431
Added SDL_PointInRect().
include/SDL_rect.h
--- 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)