GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
gp_bbox.h File Reference

A bounding box implementation. More...

#include <core/gp_types.h>
#include <core/gp_common.h>

Go to the source code of this file.

Data Structures

struct  gp_bbox
 A bounding box. More...
 

Macros

#define GP_BBOX_FMT   "[%i, %i] w=%u h=%u"
 A bounding box printf format string.
 
#define GP_BBOX_PARS(bbox)   (bbox).x, (bbox).y, (bbox).w, (bbox).h
 A bounding box printf parameters.
 

Typedefs

typedef struct gp_bbox gp_bbox
 A bounding box.
 

Functions

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 gp_bbox gp_bbox_merge (gp_bbox box1, gp_bbox box2)
 Merges two bounding boxes.
 
static gp_bbox gp_bbox_intersection (gp_bbox box1, gp_bbox box2)
 Calculates a bounding box intersection.
 
static int gp_bbox_intersects (gp_bbox box1, gp_bbox box2)
 Returns true if bouding boxes intersects.
 
static gp_bbox gp_bbox_move (gp_bbox box, gp_coord x, gp_coord y)
 Moves bounding box.
 

Detailed Description

A bounding box implementation.

Definition in file gp_bbox.h.

Function Documentation

◆ gp_bbox_empty()

static int gp_bbox_empty ( gp_bbox  box)
inlinestatic

Returns true if bounding box is empty.

Returns
Returns true on empty bounding box.

Definition at line 35 of file gp_bbox.h.

◆ gp_bbox_intersection()

static gp_bbox gp_bbox_intersection ( gp_bbox  box1,
gp_bbox  box2 
)
inlinestatic

Calculates a bounding box intersection.

Parameters
box1First bounding box.
box2Second bounding box.
Returns
An intersection of two bounding boxes.

Definition at line 90 of file gp_bbox.h.

References GP_MAX, and GP_MIN.

◆ gp_bbox_intersects()

static int gp_bbox_intersects ( gp_bbox  box1,
gp_bbox  box2 
)
inlinestatic

Returns true if bouding boxes intersects.

Parameters
box1First bounding box.
box2Second bounding box.
Returns
True if bounding boxes intersects.

Definition at line 110 of file gp_bbox.h.

◆ gp_bbox_merge()

static gp_bbox gp_bbox_merge ( gp_bbox  box1,
gp_bbox  box2 
)
inlinestatic

Merges two bounding boxes.

Parameters
box1First bounding box.
box2Second bounding box.
Returns
A bounding box that contains both bounding boxes.

Definition at line 70 of file gp_bbox.h.

References GP_MAX, and GP_MIN.

◆ gp_bbox_move()

static gp_bbox gp_bbox_move ( gp_bbox  box,
gp_coord  x,
gp_coord  y 
)
inlinestatic

Moves bounding box.

Parameters
boxA bounding box.
xAn offset to move by in horizontal direction.
yAn offset to move by in vertical direction.
Returns
A bounding box moved by x, y.

Definition at line 136 of file gp_bbox.h.

References gp_bbox_pack().

◆ gp_bbox_pack()

static gp_bbox gp_bbox_pack ( gp_coord  x,
gp_coord  y,
gp_coord  w,
gp_coord  h 
)
inlinestatic

Creates a bounding box from coordinates and size.

Parameters
xA bounding box left x coordinate.
yA bounding box top y coordinate.
wA bounding box width.
hA bounding box height.
Returns
A gp_bbox initialized from the parameters.

Definition at line 50 of file gp_bbox.h.

Referenced by gp_bbox_move().