]> git.bts.cx Git - benzene.git/blob - src/bz/types/rect.h
Initial version
[benzene.git] / src / bz / types / rect.h
1 #ifndef BZ_TYPES_RECT_H
2 #define BZ_TYPES_RECT_H
3
4 #include <bz/types/point.h>
5 #include <bz/types/size.h>
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 struct BZRect {
12 BZPoint origin;
13 BZSize size;
14 };
15 typedef struct BZRect BZRect;
16
17 static inline BZRect bzRectMake(float x, float y, float w, float h) {
18 return (BZRect){ .origin = bzPointMake(x, y), .size = bzSizeMake(w, h) };
19 }
20
21 static inline float bzRectMinX(BZRect rect) {
22 return rect.origin.x - rect.size.width / 2.0f;
23 }
24
25 static inline float bzRectMidX(BZRect rect) {
26 return rect.origin.x;
27 }
28
29 static inline float bzRectMaxX(BZRect rect) {
30 return rect.origin.x + rect.size.width / 2.0f;
31 }
32
33 static inline float bzRectMinY(BZRect rect) {
34 return rect.origin.y - rect.size.height / 2.0f;
35 }
36
37 static inline float bzRectMidY(BZRect rect) {
38 return rect.origin.y;
39 }
40
41 static inline float bzRectMaxY(BZRect rect) {
42 return rect.origin.y + rect.size.height / 2.0f;
43 }
44
45 //#define bzRectMake(x, y, w, h) ((BZRect){ .origin = {.x = (x), .y = (y)}, .size = {.width = (w), .height = (h)} })
46
47 #ifdef __cplusplus
48 }
49 #endif
50
51 #endif