Banjo API 0.0.1
Multi-purpose C99 API
Loading...
Searching...
No Matches
Rectangle
Collaboration diagram for Rectangle:

Detailed Description

Data Structures

struct  bj_rect_t
 Represents a rectangle with position and dimensions. More...
 

Typedefs

typedef struct bj_rect_t bj_rect
 Typedef for bj_rect_t.
 

Functions

bj_bool bj_rect_intersect (const bj_rect *p_rect_a, const bj_rect *p_rect_b, bj_rect *p_result)
 Computes the intersection of two bj_rect.
 

Data Structure Documentation

◆ bj_rect_t

struct bj_rect_t
Data Fields
uint16_t h The height of the rectangle.
uint16_t w The width of the rectangle.
int16_t x The x-coordinate of the rectangle's top-left corner.
int16_t y The y-coordinate of the rectangle's top-left corner.

Function Documentation

◆ bj_rect_intersect()

bj_bool bj_rect_intersect ( const bj_rect * p_rect_a,
const bj_rect * p_rect_b,
bj_rect * p_result )
Parameters
p_rect_aPointer to the first rectangle. Must not be 0.
p_rect_bPointer to the second rectangle. Must not be 0.
p_resultPointer to the rectangle where the result will be stored. Can be 0 if only checking intersection presence.
Returns
BJ_TRUE if the rectangles intersect and neither input is 0, BJ_FALSE.
Note
Both input rectangles must be valid and properly initialized. If either p_rect_a or p_rect_b is 0, the function returns 0. If p_result is 0, the function only checks for intersection presence and does not compute the intersection rectangle.

Example usage:

bj_rect rect_a = {0, 0, 10, 10};
bj_rect rect_b = {5, 5, 15, 15};
bj_rect result;
if (bj_rect_intersect(&rect_a, &rect_b, 0)) {
// There is an intersection between rect_a and rect_b.
}
struct bj_rect_t bj_rect
Typedef for bj_rect_t.
Definition rect.h:15
bj_bool bj_rect_intersect(const bj_rect *p_rect_a, const bj_rect *p_rect_b, bj_rect *p_result)
Computes the intersection of two bj_rect.