#include <stdint.h>
#include <sys/math.h>
Go to the source code of this file.
|
| #define | RECT_INIT(left, top, right, bottom) |
| |
| #define | RECT_INIT_DIM(x, y, width, height) |
| |
| #define | RECT_WIDTH(rect) ((rect)->right - (rect)->left) |
| |
| #define | RECT_HEIGHT(rect) ((rect)->bottom - (rect)->top) |
| |
| #define | RECT_AREA(rect) (RECT_WIDTH(rect) * RECT_HEIGHT(rect)) |
| |
| #define | RECT_HAS_NEGATIVE_DIMS(rect) (RECT_WIDTH(rect) < 0 || RECT_HEIGHT(rect) < 0) |
| |
| #define | RECT_EXPAND_TO_CONTAIN(rect, other) |
| |
| #define | RECT_EQUAL(rect, other) |
| |
| #define | RECT_CONTAINS(rect, other) |
| |
| #define | RECT_CONTAINS_POINT(rect, point) |
| |
| #define | RECT_OVERLAP(rect, other) |
| |
| #define | RECT_OVERLAP_STRICT(rect, other) |
| |
| #define | RECT_FIT(rect, parent) |
| |
| #define | RECT_SHRINK(rect, margin) |
| |
| #define | RECT_EXPAND(rect, margin) |
| |
| #define | RECT_SUBTRACT(result, rect, other) |
| |
| #define | RECT_INTERSECT(dest, src1, src2) |
| |
◆ RECT_AREA
◆ RECT_CONTAINS
| #define RECT_CONTAINS |
( |
|
rect, |
|
|
|
other |
|
) |
| |
Value: ((rect)->left <= (rect)->right && (rect)->top <= (rect)->bottom && (other)->left <= (other)->right && \
(other)->top <= (other)->bottom && (other)->left >= (rect)->left && (other)->right <= (rect)->right && \
(other)->top >= (rect)->top && (other)->bottom <= (rect)->bottom)
Definition at line 56 of file rect.h.
◆ RECT_CONTAINS_POINT
| #define RECT_CONTAINS_POINT |
( |
|
rect, |
|
|
|
point |
|
) |
| |
Value: ((point)->
x >= (rect)->left && (point)->
x < (rect)->right && (point)->
y >= (rect)->top && \
(point)->
y < (rect)->bottom)
Definition at line 61 of file rect.h.
◆ RECT_EQUAL
| #define RECT_EQUAL |
( |
|
rect, |
|
|
|
other |
|
) |
| |
Value: ((other)->left == (rect)->left && (other)->right == (rect)->right && (other)->top == (rect)->top && \
(other)->bottom == (rect)->bottom)
Definition at line 52 of file rect.h.
◆ RECT_EXPAND
| #define RECT_EXPAND |
( |
|
rect, |
|
|
|
margin |
|
) |
| |
Value: ({ \
(rect)->left -= margin; \
(rect)->top -= margin; \
(rect)->right += margin; \
(rect)->bottom += margin; \
})
Definition at line 89 of file rect.h.
◆ RECT_EXPAND_TO_CONTAIN
| #define RECT_EXPAND_TO_CONTAIN |
( |
|
rect, |
|
|
|
other |
|
) |
| |
Value: ({ \
(rect)->left =
MIN((rect)->left, (other)->left); \
(rect)->top =
MIN((rect)->top, (other)->top); \
(rect)->right =
MAX((rect)->right, (other)->right); \
(rect)->bottom =
MAX((rect)->bottom, (other)->bottom); \
})
Definition at line 44 of file rect.h.
◆ RECT_FIT
| #define RECT_FIT |
( |
|
rect, |
|
|
|
parent |
|
) |
| |
Value: ({ \
(rect)->left =
CLAMP((rect)->left, (parent)->left, (parent)->right); \
(rect)->top =
CLAMP((rect)->top, (parent)->top, (parent)->bottom); \
(rect)->right =
CLAMP((rect)->right, (parent)->left, (parent)->right); \
(rect)->bottom =
CLAMP((rect)->bottom, (parent)->top, (parent)->bottom); \
})
#define CLAMP(x, low, high)
Definition at line 73 of file rect.h.
◆ RECT_HAS_NEGATIVE_DIMS
◆ RECT_HEIGHT
| #define RECT_HEIGHT |
( |
|
rect | ) |
((rect)->bottom - (rect)->top) |
◆ RECT_INIT
| #define RECT_INIT |
( |
|
left, |
|
|
|
top, |
|
|
|
right, |
|
|
|
bottom |
|
) |
| |
Value:
{ \
left, top, right, bottom, \
}
Definition at line 26 of file rect.h.
◆ RECT_INIT_DIM
| #define RECT_INIT_DIM |
( |
|
x, |
|
|
|
y, |
|
|
|
width, |
|
|
|
height |
|
) |
| |
Value:
{ \
(
x), (
y), (
x) + (width), (
y) + (height), \
}
Definition at line 32 of file rect.h.
◆ RECT_INTERSECT
| #define RECT_INTERSECT |
( |
|
dest, |
|
|
|
src1, |
|
|
|
src2 |
|
) |
| |
Value: ({ \
(dest)->left =
MAX((src1)->left, (src2)->left); \
(dest)->top =
MAX((src1)->top, (src2)->top); \
(dest)->right =
MIN((src1)->right, (src2)->right); \
(dest)->bottom =
MIN((src1)->bottom, (src2)->bottom); \
})
Definition at line 129 of file rect.h.
◆ RECT_OVERLAP
| #define RECT_OVERLAP |
( |
|
rect, |
|
|
|
other |
|
) |
| |
Value: (!((rect)->right <= (other)->left || (rect)->left >= (other)->right || (rect)->bottom <= (other)->top || \
(rect)->top >= (other)->bottom))
Definition at line 65 of file rect.h.
◆ RECT_OVERLAP_STRICT
| #define RECT_OVERLAP_STRICT |
( |
|
rect, |
|
|
|
other |
|
) |
| |
Value: (!((rect)->right < (other)->left || (rect)->left > (other)->right || (rect)->bottom < (other)->top || \
(rect)->top > (other)->bottom))
Definition at line 69 of file rect.h.
◆ RECT_SHRINK
| #define RECT_SHRINK |
( |
|
rect, |
|
|
|
margin |
|
) |
| |
Value: ({ \
(rect)->left += margin; \
(rect)->top += margin; \
(rect)->right -= margin; \
(rect)->bottom -= margin; \
})
Definition at line 81 of file rect.h.
◆ RECT_SUBTRACT
| #define RECT_SUBTRACT |
( |
|
result, |
|
|
|
rect, |
|
|
|
other |
|
) |
| |
Value: ({ \
{ \
res.
rects[0] = *(rect); \
} \
else \
{ \
if ((other)->top > (rect)->top) \
{ \
} \
if ((other)->bottom < (rect)->bottom) \
{ \
} \
if ((other)->left > (rect)->left) \
{ \
res.
rects[res.
count++] = (
rect_t){(rect)->left,
MAX((rect)->top, (other)->top), (other)->left, \
MIN((rect)->bottom, (other)->bottom)}; \
} \
if ((other)->right < (rect)->right) \
{ \
res.
rects[res.
count++] = (
rect_t){(other)->right,
MAX((rect)->top, (other)->top), (rect)->right, \
MIN((rect)->bottom, (other)->bottom)}; \
} \
} \
*(result) = res; \
})
#define RECT_OVERLAP(rect, other)
Definition at line 97 of file rect.h.
◆ RECT_WIDTH
| #define RECT_WIDTH |
( |
|
rect | ) |
((rect)->right - (rect)->left) |