Banjo API 0.0.1
C99 game development API
Loading...
Searching...
No Matches
Drawing
Collaboration diagram for Drawing:

Functions

void bj_draw_line (bj_bitmap *p_bitmap, int x0, int y0, int x1, int y1, uint32_t pixel)
void bj_draw_rectangle (bj_bitmap *p_bitmap, const bj_rect *p_area, uint32_t pixel)
void bj_draw_filled_rectangle (bj_bitmap *p_bitmap, const bj_rect *p_area, uint32_t pixel)
void bj_draw_triangle (bj_bitmap *p_bitmap, int x0, int y0, int x1, int y1, int x2, int y2, uint32_t color)
void bj_draw_circle (bj_bitmap *p_bitmap, int cx, int cy, int radius, uint32_t color)
void bj_draw_filled_circle (bj_bitmap *p_bitmap, int cx, int cy, int radius, uint32_t color)
void bj_draw_polyline (bj_bitmap *p_bitmap, size_t count, const int *x, const int *y, bj_bool loop, uint32_t color)

Detailed Description

2D drawing facilities

Function Documentation

◆ bj_draw_circle()

void bj_draw_circle ( bj_bitmap * p_bitmap,
int cx,
int cy,
int radius,
uint32_t color )

Draw the outline of a circle onto a bitmap.

Uses the midpoint circle algorithm (integer arithmetic).

Parameters
p_bitmapTarget bitmap (must not be NULL).
cxX-coordinate of circle center (pixels).
cyY-coordinate of circle center (pixels).
radiusCircle radius in pixels (>= 0).
colorPixel color in 0xAARRGGBB format.

◆ bj_draw_filled_circle()

void bj_draw_filled_circle ( bj_bitmap * p_bitmap,
int cx,
int cy,
int radius,
uint32_t color )

Draw a filled circle onto a bitmap.

Fills all pixels within radius distance from (cx, cy).

Parameters
p_bitmapTarget bitmap (must not be NULL).
cxX-coordinate of circle center (pixels).
cyY-coordinate of circle center (pixels).
radiusCircle radius in pixels (>= 0).
colorPixel color in 0xAARRGGBB format.

◆ bj_draw_filled_rectangle()

void bj_draw_filled_rectangle ( bj_bitmap * p_bitmap,
const bj_rect * p_area,
uint32_t pixel )

Draws a filled rectangle in the given bitmap.

The function draws an filled rectangle by filling all pixels within p_area.

Parameters
p_bitmapThe bitmap object.
p_areaThe rectangle to draw.
pixelThe line pixel value.
Memory Safety

This function does not perform any bound checking on the pixel coordinates. It is up to you to ensure the coordinates lie between [0, bj_bitmap->width * bj_bitmap->height]. Writing outside of these bounds will result in undefined behavior or corrupted memory access.

◆ bj_draw_line()

void bj_draw_line ( bj_bitmap * p_bitmap,
int x0,
int y0,
int x1,
int y1,
uint32_t pixel )

Draws a line of pixels in the given bitmap.

The line is drawn for each pixel between p0 and p1.

Parameters
p_bitmapThe bitmap object.
x0The X coordinate of the first point in the line.
y0The Y coordinate of the first point in the line.
x1The X coordinate of the second point in the line.
y1The Y coordinate of the second point in the line.
pixelThe line pixel value.
Memory Safety

This function does not perform any bound checking on the pixel coordinates. It is up to you to ensure the coordinates lie between [0, bj_bitmap->width * bj_bitmap->height]. Writing outside of these bounds will result in undefined behavior or corrupted memory access.

◆ bj_draw_polyline()

void bj_draw_polyline ( bj_bitmap * p_bitmap,
size_t count,
const int * x,
const int * y,
bj_bool loop,
uint32_t color )

Draw a polyline from C-style coordinate arrays.

Draws line segments between successive vertex pairs (x[i], y[i]) -> (x[i+1], y[i+1]). If loop != 0 and count >= 2, an extra segment connects the last vertex to the first.

Parameters
p_bitmapTarget bitmap.
xPointer to array of x coordinates (length >= count).
yPointer to array of y coordinates (length >= count).
countNumber of vertices. Segments drawn for i = 0..count-2.
colorPixel color in 0xAARRGGBB format.
loopNonzero to close the polyline.

◆ bj_draw_rectangle()

void bj_draw_rectangle ( bj_bitmap * p_bitmap,
const bj_rect * p_area,
uint32_t pixel )

Draws a rectangle in the given bitmap.

The function draws an rectangle outline using 4 consecutive calls to bj_draw_line.

Parameters
p_bitmapThe bitmap object.
p_areaThe rectangle to draw.
pixelThe line pixel value.
Memory Safety

This function does not perform any bound checking on the pixel coordinates. It is up to you to ensure the coordinates lie between [0, bj_bitmap->width * bj_bitmap->height]. Writing outside of these bounds will result in undefined behavior or corrupted memory access.

◆ bj_draw_triangle()

void bj_draw_triangle ( bj_bitmap * p_bitmap,
int x0,
int y0,
int x1,
int y1,
int x2,
int y2,
uint32_t color )

Draws the edges of a triangle given its 3 corners.

Parameters
p_bitmapThe bitmap object.
x0The X coordinate of the first triangle vertex.
y0The Y coordinate of the first triangle vertex.
x1The X coordinate of the second triangle vertex.
y1The Y coordinate of the second triangle vertex.
x2The X coordinate of the third triangle vertex.
y2The Y coordinate of the third triangle vertex.
colorThe line color.
Memory Safety

This function does not perform any bound checking on the pixel coordinates. It is up to you to ensure the coordinates lie between [0, bj_bitmap->width * bj_bitmap->height]. Writing outside of these bounds will result in undefined behavior or corrupted memory access.