Banjo API 0.0.1
C99 game development API
|
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) |
2D drawing facilities
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).
p_bitmap | Target bitmap (must not be NULL). |
cx | X-coordinate of circle center (pixels). |
cy | Y-coordinate of circle center (pixels). |
radius | Circle radius in pixels (>= 0). |
color | Pixel color in 0xAARRGGBB format. |
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).
p_bitmap | Target bitmap (must not be NULL). |
cx | X-coordinate of circle center (pixels). |
cy | Y-coordinate of circle center (pixels). |
radius | Circle radius in pixels (>= 0). |
color | Pixel color in 0xAARRGGBB format. |
Draws a filled rectangle in the given bitmap.
The function draws an filled rectangle by filling all pixels within p_area.
p_bitmap | The bitmap object. |
p_area | The rectangle to draw. |
pixel | The line pixel value. |
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.
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.
p_bitmap | The bitmap object. |
x0 | The X coordinate of the first point in the line. |
y0 | The Y coordinate of the first point in the line. |
x1 | The X coordinate of the second point in the line. |
y1 | The Y coordinate of the second point in the line. |
pixel | The line pixel value. |
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.
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.
p_bitmap | Target bitmap. |
x | Pointer to array of x coordinates (length >= count). |
y | Pointer to array of y coordinates (length >= count). |
count | Number of vertices. Segments drawn for i = 0..count-2. |
color | Pixel color in 0xAARRGGBB format. |
loop | Nonzero to close the polyline. |
Draws a rectangle in the given bitmap.
The function draws an rectangle outline using 4 consecutive calls to bj_draw_line.
p_bitmap | The bitmap object. |
p_area | The rectangle to draw. |
pixel | The line pixel value. |
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.
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.
p_bitmap | The bitmap object. |
x0 | The X coordinate of the first triangle vertex. |
y0 | The Y coordinate of the first triangle vertex. |
x1 | The X coordinate of the second triangle vertex. |
y1 | The Y coordinate of the second triangle vertex. |
x2 | The X coordinate of the third triangle vertex. |
y2 | The Y coordinate of the third triangle vertex. |
color | The line color. |
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.