|
Banjo API 1.0.0-rc.2
Low-level C99 game development API
|
Functions | |
| void | bj_draw_line (struct bj_bitmap *bitmap, int x0, int y0, int x1, int y1, uint32_t pixel) |
| void | bj_draw_rectangle (struct bj_bitmap *bitmap, const struct bj_rect *area, uint32_t pixel) |
| void | bj_draw_filled_rectangle (struct bj_bitmap *bitmap, const struct bj_rect *area, uint32_t pixel) |
| void | bj_draw_triangle (struct bj_bitmap *bitmap, int x0, int y0, int x1, int y1, int x2, int y2, uint32_t color) |
| void | bj_draw_filled_triangle (struct bj_bitmap *bitmap, int x0, int y0, int x1, int y1, int x2, int y2, uint32_t color) |
| void | bj_draw_circle (struct bj_bitmap *bitmap, int cx, int cy, int radius, uint32_t color) |
| void | bj_draw_filled_circle (struct bj_bitmap *bitmap, int cx, int cy, int radius, uint32_t color) |
| void | bj_draw_polyline (struct bj_bitmap *bitmap, size_t count, const int *x, const int *y, bj_bool loop, uint32_t color) |
Draw lines, shapes, and outlines into a bitmap.
These functions draw simple geometric shapes into a bj_bitmap. pixels, lines, rectangles, triangles, circles, and polylines (a series of connected line segments). Each function writes directly into the destination bitmap's pixels; there's no draw queue or scene graph. The pattern is:
bj_render_target_bitmap).bj_invalidate_window.Rectangles, triangles, and circles each come in two flavours: bj_draw_rectangle / bj_draw_filled_rectangle and so on. "Outlined" draws just the edge; "filled" colours every pixel inside. Lines and polylines are obviously line-only.
drawing_2d.c for every primitive in one program, drawing_text.c for text rendering on top of these primitives. | void bj_draw_circle | ( | struct bj_bitmap * | 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).
| bitmap | Target bitmap (must not be NULL). |
| cx | X-coordinate of circle centre (pixels). |
| cy | Y-coordinate of circle centre (pixels). |
| radius | Circle radius in pixels (>= 0). |
| color | Pixel colour in 0xAARRGGBB format. |
| void bj_draw_filled_circle | ( | struct bj_bitmap * | 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).
| bitmap | Target bitmap (must not be NULL). |
| cx | X-coordinate of circle centre (pixels). |
| cy | Y-coordinate of circle centre (pixels). |
| radius | Circle radius in pixels (>= 0). |
| color | Pixel colour in 0xAARRGGBB format. |
Referenced by draw(), draw(), draw(), draw(), on_draw(), and on_draw().
| void bj_draw_filled_rectangle | ( | struct bj_bitmap * | bitmap, |
| const struct bj_rect * | area, | ||
| uint32_t | pixel ) |
Draws a filled rectangle in the given bitmap.
The function draws an filled rectangle by filling all pixels within area.
| bitmap | The bitmap object. |
| 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, struct bj_bitmap->width * struct bj_bitmap->height]. Writing outside of these bounds will result in undefined behaviour or corrupted memory access.
| void bj_draw_filled_triangle | ( | struct bj_bitmap * | bitmap, |
| int | x0, | ||
| int | y0, | ||
| int | x1, | ||
| int | y1, | ||
| int | x2, | ||
| int | y2, | ||
| uint32_t | color ) |
Draws a filled triangle given its 3 corners.
| 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 fill colour. |
This function does not perform any bound checking on the pixel coordinates. It is up to you to ensure the coordinates lie between [0, struct bj_bitmap->width * struct bj_bitmap->height]. Writing outside of these bounds will result in undefined behaviour or corrupted memory access.
Referenced by draw().
| void bj_draw_line | ( | struct bj_bitmap * | 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.
| 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, struct bj_bitmap->width * struct bj_bitmap->height]. Writing outside of these bounds will result in undefined behaviour or corrupted memory access.
Referenced by draw().
| void bj_draw_polyline | ( | struct bj_bitmap * | 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.
| 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 colour in 0xAARRGGBB format. |
| loop | Nonzero to close the polyline. |
Referenced by draw().
Draws a rectangle in the given bitmap.
The function draws an rectangle outline using 4 consecutive calls to bj_draw_line.
| bitmap | The bitmap object. |
| 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, struct bj_bitmap->width * struct bj_bitmap->height]. Writing outside of these bounds will result in undefined behaviour or corrupted memory access.
| void bj_draw_triangle | ( | struct bj_bitmap * | 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.
| 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 colour. |
This function does not perform any bound checking on the pixel coordinates. It is up to you to ensure the coordinates lie between [0, struct bj_bitmap->width * struct bj_bitmap->height]. Writing outside of these bounds will result in undefined behaviour or corrupted memory access.
Referenced by draw().