aboutsummaryrefslogtreecommitdiff
path: root/draw.h
blob: 8f8b98516bf2722aa1be4abb54236d53d8b68575 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef VIX_DRAW_H
#define VIX_DRAW_H

/* Minimal raster primitives over a packed RGB24 buffer, enough for the
 * debug overlay: rectangles, filled bars, landmark dots
 * and text. Every coordinate is in pixels and every primitive clips to the
 * canvas, so callers may pass boxes that fall partly outside the frame. */

typedef struct {
    unsigned char *px; /* w*h*3 bytes, RGB order */
    int w, h;
} vix_canvas;

typedef struct {
    unsigned char r, g, b;
} vix_rgb;

void vix_draw_rect(const vix_canvas *c, int x, int y, int w, int h, vix_rgb col, int thickness);
void vix_draw_fill(const vix_canvas *c, int x, int y, int w, int h, vix_rgb col);
void vix_draw_dot(const vix_canvas *c, int cx, int cy, int r, vix_rgb col);

/* Draws s with its top-left corner at (x, y). Glyphs are 5x7 with a one
 * pixel gap, so one character advances 6*scale pixels and the text is
 * 7*scale pixels tall. Returns the width the string occupied. */
int vix_draw_text(const vix_canvas *c, int x, int y, const char *s, vix_rgb col, int scale);

/* Width vix_draw_text would occupy, for right-aligning or centring. */
int vix_text_width(const char *s, int scale);

#endif