Banjo API 1.1.0-alpha
Low-level C99 game development API
Loading...
Searching...
No Matches
draw.h File Reference
#include <banjo/api.h>
#include <banjo/bitmap.h>
#include <banjo/error.h>
#include <banjo/math.h>
#include <banjo/pixel.h>
#include <banjo/rect.h>
Include dependency graph for draw.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define BJ_LINE_STEPPED   BJ_LINE_MODE_STEPPED
#define BJ_LINE_WATERTIGHT   BJ_LINE_MODE_WATERTIGHT

Enumerations

enum  bj_line_mode { BJ_LINE_MODE_STEPPED = 0 , BJ_LINE_MODE_WATERTIGHT }
enum  bj_polyline_end { BJ_POLYLINE_END_OPEN = 0 , BJ_POLYLINE_END_CLOSED = 1 }

Functions

void bj_draw_line (struct bj_bitmap *bitmap, int x0, int y0, int x1, int y1, uint32_t pixel)
void bj_draw_line_mode (struct bj_bitmap *bitmap, int x0, int y0, int x1, int y1, bj_line_mode mode, 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_polyline_end end, uint32_t color)
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)

Pixel enumeration

The drawing functions above answer "paint this shape".

The functions below answer a different question: "which pixels does this shape touch?" — and answer it without touching a bitmap at all.

The same walk drives both: bj_draw_line and bj_enumerate_line_pixels visit exactly the same pixels, in the same order. Only the destination differs.

This is what you want for edge walking in a software rasteriser, ray casting over a tile map, line-of-sight tests, or picking — anywhere the coordinates are the result and no pixel is ever written.

typedef bj_bool(* bj_pixel_fn) (void *user_data, int x, int y)
typedef bj_bool(* bj_cell_fn) (void *user_data, int x, int y, bj_real t)
void bj_enumerate_line_pixels (int x0, int y0, int x1, int y1, bj_pixel_fn callback, void *user_data)
void bj_line_pixels (int x0, int y0, int x1, int y1, 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)
void bj_circle_pixels (int cx, int cy, int radius, bj_pixel_fn callback, void *user_data)
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)
void bj_grid_ray_cells (bj_real x0, bj_real y0, bj_real x1, bj_real y1, bj_cell_fn callback, void *user_data)

Detailed Description

Header file for Bitmap drawing functions.

Definition in file draw.h.