Loading...
Searching...
No Matches
canvas.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <stdint.h>
9#include <stddef.h>
10#include <gui/icon_animation.h>
11#include <gui/icon.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
18typedef enum {
19 ColorWhite = 0x00,
20 ColorBlack = 0x01,
21 ColorXOR = 0x02,
22} Color;
23
25typedef enum {
26 FontPrimary,
27 FontSecondary,
28 FontKeyboard,
29 FontBigNumbers,
30
31 // Keep last for fonts number calculation
32 FontTotalNumber,
33} Font;
34
36typedef enum {
37 AlignLeft,
38 AlignRight,
39 AlignTop,
40 AlignBottom,
41 AlignCenter,
42} Align;
43
45typedef enum {
46 CanvasOrientationHorizontal,
47 CanvasOrientationHorizontalFlip,
48 CanvasOrientationVertical,
49 CanvasOrientationVerticalFlip,
51
53typedef enum {
54 CanvasDirectionLeftToRight,
55 CanvasDirectionTopToBottom,
56 CanvasDirectionRightToLeft,
57 CanvasDirectionBottomToTop,
59
61typedef struct {
62 uint8_t leading_default;
63 uint8_t leading_min;
64 uint8_t height;
65 uint8_t descender;
67
69typedef enum {
70 IconFlipNone,
71 IconFlipHorizontal,
72 IconFlipVertical,
73 IconFlipBoth,
74} IconFlip;
75
77typedef enum {
78 IconRotation0,
79 IconRotation90,
80 IconRotation180,
81 IconRotation270,
83
85typedef struct Canvas Canvas;
86
91void canvas_reset(Canvas* canvas);
92
97void canvas_commit(Canvas* canvas);
98
105size_t canvas_width(const Canvas* canvas);
106
113size_t canvas_height(const Canvas* canvas);
114
121size_t canvas_current_font_height(const Canvas* canvas);
122
130const CanvasFontParameters* canvas_get_font_params(const Canvas* canvas, Font font);
131
136void canvas_clear(Canvas* canvas);
137
143void canvas_set_color(Canvas* canvas, Color color);
144
151
156void canvas_invert_color(Canvas* canvas);
157
163void canvas_set_font(Canvas* canvas, Font font);
164
170void canvas_set_custom_u8g2_font(Canvas* canvas, const uint8_t* font);
171
179void canvas_draw_str(Canvas* canvas, int32_t x, int32_t y, const char* str);
180
194 Canvas* canvas,
195 int32_t x,
196 int32_t y,
197 Align horizontal,
198 Align vertical,
199 const char* str);
200
208uint16_t canvas_string_width(Canvas* canvas, const char* str);
209
217size_t canvas_glyph_width(Canvas* canvas, uint16_t symbol);
218
229 Canvas* canvas,
230 int32_t x,
231 int32_t y,
232 size_t width,
233 size_t height,
234 const uint8_t* compressed_bitmap_data);
235
245 Canvas* canvas,
246 int32_t x,
247 int32_t y,
248 const Icon* icon,
249 IconRotation rotation);
250
259 Canvas* canvas,
260 int32_t x,
261 int32_t y,
262 IconAnimation* icon_animation);
263
271void canvas_draw_icon(Canvas* canvas, int32_t x, int32_t y, const Icon* icon);
272
282void canvas_draw_xbm(
283 Canvas* canvas,
284 int32_t x,
285 int32_t y,
286 size_t width,
287 size_t height,
288 const uint8_t* bitmap);
289
296void canvas_draw_dot(Canvas* canvas, int32_t x, int32_t y);
297
306void canvas_draw_box(Canvas* canvas, int32_t x, int32_t y, size_t width, size_t height);
307
316void canvas_draw_frame(Canvas* canvas, int32_t x, int32_t y, size_t width, size_t height);
317
326void canvas_draw_line(Canvas* canvas, int32_t x1, int32_t y1, int32_t x2, int32_t y2);
327
335void canvas_draw_circle(Canvas* canvas, int32_t x, int32_t y, size_t radius);
336
344void canvas_draw_disc(Canvas* canvas, int32_t x, int32_t y, size_t radius);
345
357 Canvas* canvas,
358 int32_t x,
359 int32_t y,
360 size_t base,
361 size_t height,
362 CanvasDirection dir);
363
371void canvas_draw_glyph(Canvas* canvas, int32_t x, int32_t y, uint16_t ch);
372
378void canvas_set_bitmap_mode(Canvas* canvas, bool alpha);
379
390 Canvas* canvas,
391 int32_t x,
392 int32_t y,
393 size_t width,
394 size_t height,
395 size_t radius);
396
407 Canvas* canvas,
408 int32_t x,
409 int32_t y,
410 size_t width,
411 size_t height,
412 size_t radius);
413
414#ifdef __cplusplus
415}
416#endif
void canvas_draw_triangle(Canvas *canvas, int32_t x, int32_t y, size_t base, size_t height, CanvasDirection dir)
Draw triangle with given base and height lengths and their intersection coordinate.
Definition canvas.c:480
void canvas_draw_str(Canvas *canvas, int32_t x, int32_t y, const char *str)
Draw string at position of baseline defined by x, y.
Definition canvas.c:177
void canvas_draw_dot(Canvas *canvas, int32_t x, int32_t y)
Draw dot at x,y.
Definition canvas.c:410
IconFlip
Icon flip.
Definition canvas.h:69
void canvas_set_font(Canvas *canvas, Font font)
Set drawing font.
Definition canvas.c:155
void canvas_draw_disc(Canvas *canvas, int32_t x, int32_t y, size_t radius)
Draw disc at x,y with radius r.
Definition canvas.c:473
const CanvasFontParameters * canvas_get_font_params(const Canvas *canvas, Font font)
Get font parameters.
Definition canvas.c:130
void canvas_draw_box(Canvas *canvas, int32_t x, int32_t y, size_t width, size_t height)
Draw box of width, height at x,y.
Definition canvas.c:417
CanvasDirection
Font Direction.
Definition canvas.h:53
void canvas_draw_xbm(Canvas *canvas, int32_t x, int32_t y, size_t width, size_t height, const uint8_t *bitmap)
Draw XBM bitmap.
Definition canvas.c:507
void canvas_draw_rbox(Canvas *canvas, int32_t x, int32_t y, size_t width, size_t height, size_t radius)
Draw rounded-corner box of width, height at x,y, with round value raduis.
Definition canvas.c:424
void canvas_set_bitmap_mode(Canvas *canvas, bool alpha)
Set transparency mode.
Definition canvas.c:527
Font
Fonts enumeration.
Definition canvas.h:25
void canvas_draw_line(Canvas *canvas, int32_t x1, int32_t y1, int32_t x2, int32_t y2)
Draw line from x1,y1 to x2,y2.
Definition canvas.c:457
void canvas_draw_icon_ex(Canvas *canvas, int32_t x, int32_t y, const Icon *icon, IconRotation rotation)
Draw icon at position defined by x,y with rotation and flip.
Definition canvas.c:381
void canvas_set_color(Canvas *canvas, Color color)
Set drawing color.
Definition canvas.c:141
void canvas_draw_circle(Canvas *canvas, int32_t x, int32_t y, size_t radius)
Draw circle at x,y with radius r.
Definition canvas.c:466
size_t canvas_width(const Canvas *canvas)
Get Canvas width.
Definition canvas.c:109
void canvas_invert_color(Canvas *canvas)
Invert drawing color.
Definition canvas.c:151
void canvas_draw_glyph(Canvas *canvas, int32_t x, int32_t y, uint16_t ch)
Draw glyph.
Definition canvas.c:520
void canvas_commit(Canvas *canvas)
Commit canvas.
Definition canvas.c:69
CanvasOrientation
Canvas Orientation.
Definition canvas.h:45
void canvas_reset(Canvas *canvas)
Reset canvas drawing tools configuration.
Definition canvas.c:59
size_t canvas_glyph_width(Canvas *canvas, uint16_t symbol)
Get glyph width.
Definition canvas.c:234
void canvas_draw_str_aligned(Canvas *canvas, int32_t x, int32_t y, Align horizontal, Align vertical, const char *str)
Draw aligned string defined by x, y.
Definition canvas.c:185
void canvas_draw_icon_animation(Canvas *canvas, int32_t x, int32_t y, IconAnimation *icon_animation)
Draw animation at position defined by x,y.
Definition canvas.c:255
Align
Alignment enumeration.
Definition canvas.h:36
IconRotation
Icon rotation.
Definition canvas.h:77
void canvas_draw_frame(Canvas *canvas, int32_t x, int32_t y, size_t width, size_t height)
Draw frame of width, height at x,y.
Definition canvas.c:437
Color
Color enumeration.
Definition canvas.h:18
void canvas_clear(Canvas *canvas)
Clear canvas.
Definition canvas.c:136
void canvas_set_custom_u8g2_font(Canvas *canvas, const uint8_t *font)
Set custom drawing font.
Definition canvas.c:171
void canvas_set_font_direction(Canvas *canvas, CanvasDirection dir)
Set font swap Argument String Rotation Description.
Definition canvas.c:146
uint16_t canvas_string_width(Canvas *canvas, const char *str)
Get string width.
Definition canvas.c:228
size_t canvas_current_font_height(const Canvas *canvas)
Get current font height.
Definition canvas.c:119
void canvas_draw_icon(Canvas *canvas, int32_t x, int32_t y, const Icon *icon)
Draw icon at position defined by x,y.
Definition canvas.c:398
void canvas_draw_bitmap(Canvas *canvas, int32_t x, int32_t y, size_t width, size_t height, const uint8_t *compressed_bitmap_data)
Draw bitmap picture at position defined by x,y.
Definition canvas.c:239
void canvas_draw_rframe(Canvas *canvas, int32_t x, int32_t y, size_t width, size_t height, size_t radius)
Draw rounded-corner frame of width, height at x,y, with round value radius.
Definition canvas.c:444
size_t canvas_height(const Canvas *canvas)
Get Canvas height.
Definition canvas.c:114
GUI: Icon API.
GUI: IconAnimation API.
Font parameters.
Definition canvas.h:61
Canvas structure.
Definition canvas_i.h:40
Definition icon_animation_i.h:12
Definition icon_i.h:9