]> git.lizzy.rs Git - nothing.git/blobdiff - src/math/rect.h
(#886) Make RectLayer display the ids
[nothing.git] / src / math / rect.h
index 3e4c778589c53f4842c98e9595cf66f3a1264b35..16334410ab14cc234e08c4e841463062e7ba8c76 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef RECT_H_
 #define RECT_H_
 
-#include <SDL2/SDL.h>
+#include <SDL.h>
 
 #include "math/point.h"
 
@@ -30,6 +30,20 @@ Rect rect_from_sdl(const SDL_Rect *rect);
 
 Rect rects_overlap_area(Rect rect1, Rect rect2);
 
+static inline Point rect_position(Rect rect)
+{
+    return vec(rect.x, rect.y);
+}
+
+static inline Rect rect_scale(Rect rect, float d)
+{
+    rect.x -= d;
+    rect.y -= d;
+    rect.w += d * 2.0f;
+    rect.h += d * 2.0f;
+    return rect;
+}
+
 int rect_contains_point(Rect rect, Point p);
 
 int rects_overlap(Rect rect1, Rect rect2);