21 RArea area = {
x,
y, width, height };
51 RArea area = { -1, -1, -1, -1 };
75 return self->
x + self->
width - 1;
85 return self->
y + self->
height - 1;
109 x1 =
max(other->
x, self->
x);
112 y1 =
max(other->
y, self->
y);
115 return RAreaNew(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
198 if(self->
width == other->
width && self->
x == other->
x) {
232 const int min_x =
min(self->
x, other->
x);
234 const int max_width = max_x - min_x + 1;
239 const RArea *top, *bot;
240 if(self->
y < other->
y) {
255 if(bot->
y != top->
y) {
348 const int min_y =
min(self->
y, other->
y);
350 const int max_height = max_y - min_y + 1;
355 const RArea *left, *right;
356 if(self->
x < other->
x) {
369 if(right->
x != left->
x) {
413 fprintf(stderr,
"[x=%d y=%d w=%d h=%d]", self->
x, self->
y, self->
width,
RArea RAreaInvalid(void)
Return a facially-invalid RArea.
RArea RAreaNew(int x, int y, int width, int height)
Construct an RArea from given components.
RArea RAreaIntersect(const RArea *self, const RArea *other)
Return an RArea describing the intersection of two RArea's.
int RAreaArea(const RArea *self)
Return the area of an RArea.
RAreaList * RAreaHorizontalUnion(const RArea *self, const RArea *other)
Create a list of maximal horizontal stripes of two RArea's.
bool RAreaIsIntersect(const RArea *self, const RArea *other)
Do two areas intersect?
RArea * RAreaNewStatic(int x, int y, int width, int height)
Return a pointer to a static newly constructed RArea.
bool RAreaIsValid(const RArea *self)
Is an RArea facially valid?
void RAreaPrint(const RArea *self)
Pretty-print an RArea.
int RAreaY2(const RArea *self)
Return the bottom edge of an RArea.
int RAreaX2(const RArea *self)
Return the right edge of an RArea.
RAreaList * RAreaVerticalUnion(const RArea *self, const RArea *other)
Create a list of maximal vertical stripes of two RArea's.
bool RAreaContainsXY(const RArea *self, int x, int y)
Is a given coordinate inside a RArea?
RAreaList * RAreaListNew(int cap,...)
Create an RAreaList from a set of RArea's.
void RAreaListAdd(RAreaList *self, const RArea *area)
Add an RArea onto an RAreaList.
A particular extent of space.
static int min(int a, int b)
static int max(int a, int b)