mikroSDK Reference Manual
lv_canvas.h
Go to the documentation of this file.
1
6#ifndef LV_CANVAS_H
7#define LV_CANVAS_H
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13/*********************
14 * INCLUDES
15 *********************/
16#include "../lv_conf_internal.h"
17
18#if LV_USE_CANVAS != 0
19
20#include "../core/lv_obj.h"
21#include "../widgets/lv_img.h"
22#include "../draw/lv_draw_img.h"
23
24/*********************
25 * DEFINES
26 *********************/
27
28/**********************
29 * TYPEDEFS
30 **********************/
31extern const lv_obj_class_t lv_canvas_class;
32
33/*Data of canvas*/
34typedef struct {
35 lv_img_t img;
36 lv_img_dsc_t dsc;
37} lv_canvas_t;
38
39/**********************
40 * GLOBAL PROTOTYPES
41 **********************/
42
48lv_obj_t * lv_canvas_create(lv_obj_t * parent);
49
50/*=====================
51 * Setter functions
52 *====================*/
53
66void lv_canvas_set_buffer(lv_obj_t * canvas, void * buf, lv_coord_t w, lv_coord_t h, lv_img_cf_t cf);
67
75void lv_canvas_set_px_color(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t c);
76
80static inline void lv_canvas_set_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_color_t c)
81{
82 lv_canvas_set_px_color(canvas, x, y, c);
83}
84
92void lv_canvas_set_px_opa(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_opa_t opa);
93
94
105void lv_canvas_set_palette(lv_obj_t * canvas, uint8_t id, lv_color_t c);
106
107/*=====================
108 * Getter functions
109 *====================*/
110
118lv_color_t lv_canvas_get_px(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y);
119
125lv_img_dsc_t * lv_canvas_get_img(lv_obj_t * canvas);
126
127/*=====================
128 * Other functions
129 *====================*/
130
141void lv_canvas_copy_buf(lv_obj_t * canvas, const void * to_copy, lv_coord_t x, lv_coord_t y, lv_coord_t w,
142 lv_coord_t h);
143
159void lv_canvas_transform(lv_obj_t * canvas, lv_img_dsc_t * img, int16_t angle, uint16_t zoom, lv_coord_t offset_x,
160 lv_coord_t offset_y,
161 int32_t pivot_x, int32_t pivot_y, bool antialias);
162
169void lv_canvas_blur_hor(lv_obj_t * canvas, const lv_area_t * area, uint16_t r);
170
177void lv_canvas_blur_ver(lv_obj_t * canvas, const lv_area_t * area, uint16_t r);
178
185void lv_canvas_fill_bg(lv_obj_t * canvas, lv_color_t color, lv_opa_t opa);
186
196void lv_canvas_draw_rect(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t w, lv_coord_t h,
197 const lv_draw_rect_dsc_t * draw_dsc);
198
208void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w,
209 lv_draw_label_dsc_t * draw_dsc, const char * txt);
210
219void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const void * src,
220 const lv_draw_img_dsc_t * draw_dsc);
221
229void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt,
230 const lv_draw_line_dsc_t * draw_dsc);
231
239void lv_canvas_draw_polygon(lv_obj_t * canvas, const lv_point_t points[], uint32_t point_cnt,
240 const lv_draw_rect_dsc_t * draw_dsc);
241
252void lv_canvas_draw_arc(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t r, int32_t start_angle,
253 int32_t end_angle, const lv_draw_arc_dsc_t * draw_dsc);
254
255/**********************
256 * MACROS
257 **********************/
258#define LV_CANVAS_BUF_SIZE_TRUE_COLOR(w, h) LV_IMG_BUF_SIZE_TRUE_COLOR(w, h)
259#define LV_CANVAS_BUF_SIZE_TRUE_COLOR_CHROMA_KEYED(w, h) LV_IMG_BUF_SIZE_TRUE_COLOR_CHROMA_KEYED(w, h)
260#define LV_CANVAS_BUF_SIZE_TRUE_COLOR_ALPHA(w, h) LV_IMG_BUF_SIZE_TRUE_COLOR_ALPHA(w, h)
261
262/*+ 1: to be sure no fractional row*/
263#define LV_CANVAS_BUF_SIZE_ALPHA_1BIT(w, h) LV_IMG_BUF_SIZE_ALPHA_1BIT(w, h)
264#define LV_CANVAS_BUF_SIZE_ALPHA_2BIT(w, h) LV_IMG_BUF_SIZE_ALPHA_2BIT(w, h)
265#define LV_CANVAS_BUF_SIZE_ALPHA_4BIT(w, h) LV_IMG_BUF_SIZE_ALPHA_4BIT(w, h)
266#define LV_CANVAS_BUF_SIZE_ALPHA_8BIT(w, h) LV_IMG_BUF_SIZE_ALPHA_8BIT(w, h)
267
268/*4 * X: for palette*/
269#define LV_CANVAS_BUF_SIZE_INDEXED_1BIT(w, h) LV_IMG_BUF_SIZE_INDEXED_1BIT(w, h)
270#define LV_CANVAS_BUF_SIZE_INDEXED_2BIT(w, h) LV_IMG_BUF_SIZE_INDEXED_2BIT(w, h)
271#define LV_CANVAS_BUF_SIZE_INDEXED_4BIT(w, h) LV_IMG_BUF_SIZE_INDEXED_4BIT(w, h)
272#define LV_CANVAS_BUF_SIZE_INDEXED_8BIT(w, h) LV_IMG_BUF_SIZE_INDEXED_8BIT(w, h)
273
274#endif /*LV_USE_CANVAS*/
275
276#ifdef __cplusplus
277} /*extern "C"*/
278#endif
279
280#endif /*LV_CANVAS_H*/
Definition lv_obj_class.h:49
Definition lv_obj.h:174
Definition lv_area.h:43
Definition lv_draw_arc.h:28
Definition lv_draw_img.h:32
Definition lv_draw_label.h:30
Definition lv_draw_line.h:28
Definition lv_draw_rect.h:32
Definition lv_img_buf.h:141
Definition lv_area.h:37