Banjo API 0.0.1
Multi-purpose C99 API
Loading...
Searching...
No Matches
Drawing

2D drawing facilities More...

Collaboration diagram for Drawing:

Detailed Description

Functions

void bj_bitmap_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.
 
void bj_bitmap_draw_rectangle (bj_bitmap *p_bitmap, const bj_rect *p_area, uint32_t pixel)
 Draws a rectangle in the given bitmap.
 
void bj_bitmap_draw_filled_rectangle (bj_bitmap *p_bitmap, const bj_rect *p_area, uint32_t pixel)
 Draws a filled rectangle in the given bitmap.
 
void bj_bitmap_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.
 

Function Documentation

◆ bj_bitmap_draw_filled_rectangle()

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

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_bitmap_draw_line()

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

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.

Examples
drawing_2d.c.

◆ bj_bitmap_draw_rectangle()

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

The function draws an rectangle outline using 4 consecutive calls to bj_bitmap_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.

Examples
drawing_2d.c.

◆ bj_bitmap_draw_triangle()

void bj_bitmap_draw_triangle ( bj_bitmap * p_bitmap,
int x0,
int y0,
int x1,
int y1,
int x2,
int y2,
uint32_t color )
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.

Examples
drawing_2d.c.