37 return box.w == 0 || box.h == 0;
73 .x =
GP_MIN(box1.x, box2.x),
74 .y =
GP_MIN(box1.y, box2.y),
75 .w =
GP_MAX(box1.x + box1.w, box2.x + box2.w) -
GP_MIN(box1.x, box2.x),
76 .h =
GP_MAX(box1.y + box1.h, box2.y + box2.h) -
GP_MIN(box1.y, box2.y),
93 .x =
GP_MAX(box1.x, box2.x),
94 .y =
GP_MAX(box1.y, box2.y),
95 .w =
GP_MIN(box1.x + box1.w, box2.x + box2.w) -
GP_MAX(box1.x, box2.x),
96 .h =
GP_MIN(box1.y + box1.h, box2.y + box2.h) -
GP_MAX(box1.y, box2.y),
112 if (box1.x > box2.x + (
gp_coord)box2.w)
115 if (box2.x > box1.x + (
gp_coord)box1.w)
118 if (box1.y > box2.y + (
gp_coord)box2.h)
121 if (box2.y > box1.y + (
gp_coord)box1.h)
138 return gp_bbox_pack(box.x + x, box.y + y, box.w, box.h);
142#define GP_BBOX_FMT "[%i, %i] w=%u h=%u"
144#define GP_BBOX_PARS(bbox) (bbox).x, (bbox).y, (bbox).w, (bbox).h
#define GP_MAX(a, b)
Returns a maximum of the two numbers.
#define GP_MIN(a, b)
Returns a minimum of the two numbers.
int gp_coord
Integer type for coordinates i.e. x, y, ...
unsigned int gp_size
Integer type for sizes i.e. w, h, ...
static gp_bbox gp_bbox_intersection(gp_bbox box1, gp_bbox box2)
Calculates a bounding box intersection.
static gp_bbox gp_bbox_move(gp_bbox box, gp_coord x, gp_coord y)
Moves bounding box.
static gp_bbox gp_bbox_merge(gp_bbox box1, gp_bbox box2)
Merges two bounding boxes.
static int gp_bbox_empty(gp_bbox box)
Returns true if bounding box is empty.
static gp_bbox gp_bbox_pack(gp_coord x, gp_coord y, gp_coord w, gp_coord h)
Creates a bounding box from coordinates and size.
static int gp_bbox_intersects(gp_bbox box1, gp_bbox box2)
Returns true if bouding boxes intersects.