Commits

illume committed eb3dc1a

Return empty rect if coordinates make rect off screen. Fixes #123.

  • Participants
  • Parent commits ab2d5ae

Comments (0)

Files changed (1)

File src/surface.c

         sdlrect.y = rect->y;
         sdlrect.w = rect->w;
         sdlrect.h = rect->h;
-        
-
-
 
         // clip the rect to be within the surface.
+        if(sdlrect.x + sdlrect.w <= 0 || sdlrect.y + sdlrect.h <= 0) {
+            sdlrect.w = 0;
+            sdlrect.h = 0;
+        }
+
         if (sdlrect.x < 0) {
             sdlrect.x = 0;
         }
             sdlrect.h = sdlrect.h + (surf->h - (sdlrect.y + sdlrect.h));
         }
 
+        /* printf("%d, %d, %d, %d\n", sdlrect.x, sdlrect.y, sdlrect.w, sdlrect.h); */
 
 
         if (blendargs != 0) {