46typedef uint16_t gfx_color_t;
49#define GFX_RGB(r, g, b) \
50 ((gfx_color_t)((((uint16_t)(r) & 0xF8u) << 8) | \
51 (((uint16_t)(g) & 0xFCu) << 3) | \
52 (((uint16_t)(b) & 0xF8u) >> 3)))
54#define GFX_BLACK GFX_RGB(0, 0, 0)
55#define GFX_WHITE GFX_RGB(255, 255, 255)
56#define GFX_RED GFX_RGB(255, 0, 0)
57#define GFX_GREEN GFX_RGB(0, 255, 0)
58#define GFX_BLUE GFX_RGB(0, 0, 255)
59#define GFX_YELLOW GFX_RGB(255, 255, 0)
60#define GFX_CYAN GFX_RGB(0, 255, 255)
61#define GFX_MAGENTA GFX_RGB(255, 0, 255)
62#define GFX_GREY(v) GFX_RGB(v, v, v)
66static inline void gfx_unpack(gfx_color_t c, uint8_t *r, uint8_t *g, uint8_t *b)
68 uint8_t r5 = (uint8_t)((c >> 11) & 0x1Fu);
69 uint8_t g6 = (uint8_t)((c >> 5) & 0x3Fu);
70 uint8_t b5 = (uint8_t)(c & 0x1Fu);
71 if (r) { *r = (uint8_t)((r5 << 3) | (r5 >> 2)); }
72 if (g) { *g = (uint8_t)((g6 << 2) | (g6 >> 4)); }
73 if (b) { *b = (uint8_t)((b5 << 3) | (b5 >> 2)); }
77gfx_color_t
gfx_lerp(gfx_color_t a, gfx_color_t b, uint8_t t);
91static inline int16_t gfx_i16(
int v)
93 if (v < INT16_MIN) {
return INT16_MIN; }
94 if (v > INT16_MAX) {
return INT16_MAX; }
98static inline gfx_rect_t gfx_rect_make(
int x,
int y,
int w,
int h)
102 long x1 = (long)x + (
long)w;
103 long y1 = (long)y + (
long)h;
104 int16_t rx = gfx_i16(x);
105 int16_t ry = gfx_i16(y);
106 if (x1 > INT16_MAX) { x1 = INT16_MAX; }
107 if (x1 < INT16_MIN) { x1 = INT16_MIN; }
108 if (y1 > INT16_MAX) { y1 = INT16_MAX; }
109 if (y1 < INT16_MIN) { y1 = INT16_MIN; }
110 gfx_rect_t r = { rx, ry, gfx_i16((
int)(x1 - rx)), gfx_i16((
int)(y1 - ry)) };
114static inline bool gfx_rect_empty(
gfx_rect_t r)
116 return r.w <= 0 || r.h <= 0;
119static inline bool gfx_rect_contains(
gfx_rect_t r,
int x,
int y)
121 return x >= r.x && y >= r.y && x < r.x + r.w && y < r.y + r.h;
142 int width,
int height, int32_t stride);
157void gfx_pixel(
gfx_canvas_t *c,
int x,
int y, gfx_color_t color);
161void gfx_fill_rect(
gfx_canvas_t *c,
int x,
int y,
int w,
int h, gfx_color_t color);
162void gfx_draw_rect(
gfx_canvas_t *c,
int x,
int y,
int w,
int h, gfx_color_t color);
163void gfx_hline(
gfx_canvas_t *c,
int x,
int y,
int w, gfx_color_t color);
164void gfx_vline(
gfx_canvas_t *c,
int x,
int y,
int h, gfx_color_t color);
165void gfx_line(
gfx_canvas_t *c,
int x0,
int y0,
int x1,
int y1, gfx_color_t color);
167 int thickness, gfx_color_t color);
169void gfx_draw_circle(
gfx_canvas_t *c,
int cx,
int cy,
int r, gfx_color_t color);
180 int thickness, gfx_color_t col);
181void gfx_fill_circle(
gfx_canvas_t *c,
int cx,
int cy,
int r, gfx_color_t color);
188void gfx_arc(
gfx_canvas_t *c,
int cx,
int cy,
int r,
int thickness,
189 float a0_deg,
float a1_deg, gfx_color_t col);
197void gfx_arc_fade(
gfx_canvas_t *c,
int cx,
int cy,
int r,
int thickness,
198 float a0_deg,
float a1_deg, gfx_color_t col,
199 gfx_color_t into,
float fade_deg);
201void gfx_draw_round_rect(
gfx_canvas_t *c,
int x,
int y,
int w,
int h,
202 int r, gfx_color_t color);
203void gfx_fill_round_rect(
gfx_canvas_t *c,
int x,
int y,
int w,
int h,
204 int r, gfx_color_t color);
212void gfx_fill_chamfer_rect(
gfx_canvas_t *c,
int x,
int y,
int w,
int h,
213 int cut, gfx_color_t color);
214void gfx_draw_chamfer_rect(
gfx_canvas_t *c,
int x,
int y,
int w,
int h,
215 int cut, gfx_color_t color);
216void gfx_fill_chamfer_rect_ex(
gfx_canvas_t *c,
int x,
int y,
int w,
int h,
217 int tl,
int tr,
int br,
int bl, gfx_color_t color);
218void gfx_draw_chamfer_rect_ex(
gfx_canvas_t *c,
int x,
int y,
int w,
int h,
219 int tl,
int tr,
int br,
int bl, gfx_color_t color);
223 gfx_color_t a, gfx_color_t b);
229 int w,
int h, int32_t src_stride);
232 int w,
int h, int32_t src_stride, gfx_color_t key);
236 int w,
int h, gfx_color_t fg);
333 gfx_color_t fg,
int scale);
336 const gfx_font_t *font, gfx_color_t fg,
int scale);
339 const gfx_font_t *font, gfx_color_t fg, gfx_color_t bg,
int scale);
371 const gfx_font_t *font,
int scale, uint8_t alpha,
372 float angle_deg, uint32_t *out,
int max_out);
375 const gfx_font_t *font, gfx_color_t fg,
int scale,
376 uint8_t alpha,
float angle_deg);
386 const gfx_font_t *font, gfx_color_t fg,
int scale,
402void gfx_trace_text(
const gfx_canvas_t *c,
int x,
int y,
int w,
int h,
404void gfx_trace_box(
const gfx_canvas_t *c,
int x,
int y,
int w,
int h);
#define s
Short name for esc_stick_s inside the five stick-class files.
Definition esc_stick_panel_int.h:295
void gfx_blit_key(gfx_canvas_t *c, int x, int y, const gfx_color_t *src, int w, int h, int32_t src_stride, gfx_color_t key)
Definition gfx.c:663
gfx_color_t gfx_pixel_get(const gfx_canvas_t *c, int x, int y)
Definition gfx.c:182
void gfx_thick_line(gfx_canvas_t *c, int x0, int y0, int x1, int y1, int thickness, gfx_color_t color)
A line thickness px wide: a disc of half that radius stamped at each pixel of the line from (x0,...
Definition gfx.c:319
void gfx_blit_1bpp(gfx_canvas_t *c, int x, int y, const uint8_t *bits, int w, int h, gfx_color_t fg)
Definition gfx.c:690
void gfx_blit(gfx_canvas_t *c, int x, int y, const gfx_color_t *src, int w, int h, int32_t src_stride)
Definition gfx.c:639
void gfx_fill_rect_gradient(gfx_canvas_t *c, int x, int y, int w, int h, gfx_color_t a, gfx_color_t b)
Definition gfx.c:625
gfx_color_t gfx_lerp(gfx_color_t a, gfx_color_t b, uint8_t t)
Definition gfx.c:79
bool gfx_canvas_sub(const gfx_canvas_t *src, gfx_rect_t window, gfx_canvas_t *out)
Definition gfx.c:133
void gfx_fill_circle_aa(gfx_canvas_t *c, int cx, int cy, int r, gfx_color_t col)
gfx_fill_circle_aaf() on whole pixels.
Definition gfx.c:867
bool gfx_clip_set(gfx_canvas_t *c, gfx_rect_t r)
Definition gfx.c:161
void gfx_canvas_init(gfx_canvas_t *c, gfx_color_t *pixels, int width, int height, int32_t stride)
Definition gfx.c:114
bool gfx_rect_intersect(gfx_rect_t a, gfx_rect_t b, gfx_rect_t *out)
Definition gfx.c:93
void gfx_capsule_aa(gfx_canvas_t *c, int ax, int ay, int bx, int by, int thickness, gfx_color_t col)
gfx_capsule_aaf() on whole pixels.
Definition gfx.c:966
bool gfx_clip_intersect(gfx_canvas_t *c, gfx_rect_t r)
Definition gfx.c:169
static void gfx_unpack(gfx_color_t c, uint8_t *r, uint8_t *g, uint8_t *b)
Definition gfx.h:66
const gfx_font_t gfx_font_16x28
const gfx_font_t gfx_font_12x24
12x24 monospaced, ASCII 0x20..0x7E and the German letters. Cap height 15px. Prose: help text,...
const gfx_font_t gfx_font_num_32x44
32x44 digits and punctuation, 0x20..0x3A. Cap height 40px. Hero numerals on the 1024 x 600 panel.
const gfx_font_t gfx_font_num_24x30
const gfx_font_t gfx_font_20x36
20x36 monospaced, ASCII 0x20..0x7E and the German letters. Cap height 23px. Headings,...
const gfx_font_t gfx_font_10x20
10x20 monospaced, ASCII 0x20..0x7E and the German letters. Cap height 12px. Labels,...
const gfx_font_t gfx_font_8x16
int gfx_seg_width(const char *s, const gfx_seg_style_t *st)
Definition gfx_seg.c:199
int gfx_seg_text(gfx_canvas_t *c, int x, int y, const char *s, const gfx_seg_style_t *st, gfx_color_t on, gfx_color_t off)
Definition gfx_seg.c:211
int gfx_text_bg(gfx_canvas_t *c, int x, int y, const char *s, const gfx_font_t *font, gfx_color_t fg, gfx_color_t bg, int scale)
Definition gfx_text.c:302
void gfx_text_in(gfx_canvas_t *c, gfx_rect_t box, const char *s, const gfx_font_t *font, gfx_color_t fg, int scale, gfx_align_t align)
Definition gfx_text.c:316
size_t gfx_text_prefix(const char *s, int cells)
Definition gfx_text.c:77
int gfx_text_height(const gfx_font_t *font, int scale)
Definition gfx_text.c:137
int gfx_text_cells(const char *s)
Definition gfx_text.c:65
void gfx_text_rotated(gfx_canvas_t *c, int cx, int cy, const char *s, const gfx_font_t *font, gfx_color_t fg, int scale, uint8_t alpha, float angle_deg)
s rotated by angle_deg about (cx, cy), stencilled onto the share alpha of its pixels by an ordered di...
Definition gfx_text.c:502
int gfx_text_width(const gfx_font_t *font, const char *s, int scale)
Definition gfx_text.c:148
int gfx_text(gfx_canvas_t *c, int x, int y, const char *s, const gfx_font_t *font, gfx_color_t fg, int scale)
Definition gfx_text.c:286
int gfx_text_rotated_points(gfx_canvas_t *c, int cx, int cy, const char *s, const gfx_font_t *font, int scale, uint8_t alpha, float angle_deg, uint32_t *out, int max_out)
Definition gfx_text.c:510
uint32_t gfx_utf8_next(const char **s)
Definition gfx_text.c:17
int gfx_char(gfx_canvas_t *c, int x, int y, char ch, const gfx_font_t *font, gfx_color_t fg, int scale)
Definition gfx_text.c:258
gfx_rect_t clip
Definition gfx.h:134
int16_t width
Definition gfx.h:131
int16_t height
Definition gfx.h:132
gfx_color_t * pixels
Definition gfx.h:130
int32_t stride
Definition gfx.h:133
const uint16_t * extra
Definition gfx.h:260
uint8_t first
Definition gfx.h:257
uint8_t extra_count
Definition gfx.h:259
uint8_t last
Definition gfx.h:258
uint8_t height
Definition gfx.h:254
uint8_t bpp
Definition gfx.h:256
uint8_t width
Definition gfx.h:253
uint8_t bytes_per_row
Definition gfx.h:255
const uint8_t * glyphs
Definition gfx.h:251
bool ghost
Definition gfx.h:298
int slant
Definition gfx.h:297
int gap
Definition gfx.h:296
int thickness
Definition gfx.h:295
int digit_w
Definition gfx.h:293