Banjo API 1.1.0-alpha
Low-level C99 game development API
Loading...
Searching...
No Matches
draw.h
Go to the documentation of this file.
1
58#ifndef BJ_DRAW_H
59#define BJ_DRAW_H
60#include <banjo/api.h>
61#include <banjo/bitmap.h>
62#include <banjo/error.h>
63#include <banjo/math.h>
64#include <banjo/pixel.h>
65#include <banjo/rect.h>
66
95
97#define BJ_LINE_STEPPED BJ_LINE_MODE_STEPPED
99#define BJ_LINE_WATERTIGHT BJ_LINE_MODE_WATERTIGHT
100
111
135 struct bj_bitmap* bitmap,
136 int x0,
137 int y0,
138 int x1,
139 int y1,
140 uint32_t pixel
141);
142
162 struct bj_bitmap* bitmap,
163 int x0,
164 int y0,
165 int x1,
166 int y1,
167 bj_line_mode mode,
168 uint32_t pixel
169);
170
184 struct bj_bitmap* bitmap,
185 const struct bj_rect* area,
186 uint32_t pixel
187);
188
200 struct bj_bitmap* bitmap,
201 const struct bj_rect* area,
202 uint32_t pixel
203);
204
218 struct bj_bitmap* bitmap,
219 int x0,
220 int y0,
221 int x1,
222 int y1,
223 int x2,
224 int y2,
225 uint32_t color
226);
227
245 struct bj_bitmap* bitmap,
246 int x0,
247 int y0,
248 int x1,
249 int y1,
250 int x2,
251 int y2,
252 uint32_t color
253);
254
268 struct bj_bitmap* bitmap,
269 int cx,
270 int cy,
271 int radius,
272 uint32_t color
273);
274
289 struct bj_bitmap* bitmap,
290 int cx,
291 int cy,
292 int radius,
293 uint32_t color
294);
295
316 struct bj_bitmap* bitmap,
317 size_t count,
318 const int* x,
319 const int* y,
320 bj_polyline_end end,
321 uint32_t color
322);
323
346 struct bj_bitmap* bitmap,
347 size_t count,
348 const int* x,
349 const int* y,
350 bj_polyline_end end,
351 bj_line_mode mode,
352 uint32_t color
353);
354
372
389 void* user_data,
390 int x,
391 int y
392);
393
409 void* user_data,
410 int x,
411 int y,
412 bj_real t
413);
414
438 int x0,
439 int y0,
440 int x1,
441 int y1,
442 bj_pixel_fn callback,
443 void* user_data
444);
445
447BANJO_EXPORT void bj_line_pixels(int x0, int y0, int x1, int y1,
448 bj_pixel_fn callback, void* user_data);
449
473 int cx,
474 int cy,
475 int radius,
476 bj_pixel_fn callback,
477 void* user_data
478);
479
481BANJO_EXPORT void bj_circle_pixels(int cx, int cy, int radius,
482 bj_pixel_fn callback, void* user_data);
483
510 bj_real x0,
511 bj_real y0,
512 bj_real x1,
513 bj_real y1,
514 bj_cell_fn callback,
515 void* user_data
516);
517
520 bj_cell_fn callback, void* user_data);
521
523
524#endif
General-purpose definitions for Banjo API.
Header file for Bitmap type.
Recoverable error handling.
#define BANJO_EXPORT
Definition api.h:179
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:264
struct bj_bitmap bj_bitmap
Definition api.h:340
void bj_draw_rectangle(struct bj_bitmap *bitmap, const struct bj_rect *area, uint32_t pixel)
Draws a rectangle in the given bitmap.
void bj_grid_ray_cells(bj_real x0, bj_real y0, bj_real x1, bj_real y1, bj_cell_fn callback, void *user_data)
void bj_enumerate_line_pixels(int x0, int y0, int x1, int y1, bj_pixel_fn callback, void *user_data)
Reports every pixel a line touches, without drawing anything.
void bj_draw_polyline_mode(struct bj_bitmap *bitmap, size_t count, const int *x, const int *y, bj_polyline_end end, bj_line_mode mode, uint32_t color)
Draw a polyline, choosing which pixels its segments claim.
void bj_draw_polyline(struct bj_bitmap *bitmap, size_t count, const int *x, const int *y, bj_polyline_end end, uint32_t color)
Draw a polyline from C-style coordinate arrays.
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.
void bj_draw_line_mode(struct bj_bitmap *bitmap, int x0, int y0, int x1, int y1, bj_line_mode mode, uint32_t pixel)
Draws a line of pixels, choosing which ones it claims.
bj_polyline_end
Whether a polyline's last vertex connects back to its first.
Definition draw.h:107
bj_bool(* bj_cell_fn)(void *user_data, int x, int y, bj_real t)
Callback invoked once per grid cell entered by a ray.
Definition draw.h:408
void bj_line_pixels(int x0, int y0, int x1, int y1, bj_pixel_fn callback, void *user_data)
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.
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.
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.
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.
void bj_enumerate_grid_ray_cells(bj_real x0, bj_real y0, bj_real x1, bj_real y1, bj_cell_fn callback, void *user_data)
Reports every grid cell a ray passes through.
bj_line_mode
How a line decides which pixels it touches.
Definition draw.h:82
void bj_circle_pixels(int cx, int cy, int radius, bj_pixel_fn callback, void *user_data)
void bj_enumerate_circle_pixels(int cx, int cy, int radius, bj_pixel_fn callback, void *user_data)
Reports every pixel a circle outline touches, without drawing anything.
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.
bj_bool(* bj_pixel_fn)(void *user_data, int x, int y)
Callback invoked once per visited pixel.
Definition draw.h:388
@ BJ_POLYLINE_END_CLOSED
An extra segment closes the polyline into a loop.
Definition draw.h:109
@ BJ_POLYLINE_END_OPEN
The polyline is left open.
Definition draw.h:108
@ BJ_LINE_MODE_WATERTIGHT
No diagonal steps: consecutive pixels differ along one axis only, so the line has no gap at any corne...
Definition draw.h:93
@ BJ_LINE_MODE_STEPPED
Diagonal steps allowed, one pixel per step along the major axis.
Definition draw.h:87
float bj_real
Selected real type for float configuration.
Definition math.h:80
Axis-aligned rectangle: a top-left corner plus a width and height.
Definition rect.h:33
C99 math shim with bj_real precision type and scalar utilities.
Header file for general pixel manipulation facilities.
Axis-aligned rectangle in pixel coordinates.