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 39 of file gp_bbox.h.

References gp_bbox::h, and gp_bbox::w.

Referenced by gp_widget_ops_blit().

◆ 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 94 of file gp_bbox.h.

References GP_MAX, GP_MIN, gp_bbox::h, gp_bbox::w, gp_bbox::x, and gp_bbox::y.

◆ 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 114 of file gp_bbox.h.

References gp_bbox::h, gp_bbox::w, gp_bbox::x, and gp_bbox::y.

◆ 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 74 of file gp_bbox.h.

References GP_MAX, GP_MIN, gp_bbox::h, gp_bbox::w, gp_bbox::x, and gp_bbox::y.

Referenced by gp_widget_ops_blit().

◆ 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 140 of file gp_bbox.h.

References gp_bbox_pack(), gp_bbox::h, gp_bbox::w, gp_bbox::x, and gp_bbox::y.

◆ 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 54 of file gp_bbox.h.

References gp_bbox::x.

Referenced by gp_bbox_move(), and gp_widget_ops_blit().