[qwaq] Add function to merge extents

It's pretty much the union of two rectangles with the same origin.
This commit is contained in:
Bill Currie 2020-03-19 13:51:14 +09:00
parent 03f87d6f27
commit 6a18b1dd55
2 changed files with 7 additions and 0 deletions

View file

@ -20,6 +20,7 @@ typedef struct Rect_s {
@extern Rect makeRect (int xpos, int ypos, int xlen, int ylen);
@extern Point makePoint (int x, int y);
@extern Extent makeExtent (int width, int height);
@extern Extent mergeExtents (Extent a, Extent b);
//XXX will not work if point or rect point to a local variabl
@extern int rectContainsPoint (Rect *rect, Point *point);
@extern Rect clipRect (Rect clipRect, Rect rect);

View file

@ -39,6 +39,12 @@ Extent makeExtent (int width, int height)
return {width, height};
}
Extent mergeExtents (Extent a, Extent b)
{
return { a.width < b.width ? b.width : a.width,
a.height < b.height ? b.height : a.height };
}
int
rectContainsPoint (Rect *rect, Point *point)
{