2022-11-21 23:08:32 +01:00
|
|
|
#include "../../lv_examples.h"
|
|
|
|
#if LV_USE_CANVAS && LV_FONT_MONTSERRAT_18 && LV_BUILD_EXAMPLES
|
|
|
|
|
|
|
|
#define CANVAS_WIDTH 50
|
|
|
|
#define CANVAS_HEIGHT 50
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw a text to the canvas
|
|
|
|
*/
|
|
|
|
void lv_example_canvas_4(void)
|
|
|
|
{
|
|
|
|
/*Create a buffer for the canvas*/
|
|
|
|
static uint8_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT)];
|
|
|
|
|
|
|
|
/*Create a canvas and initialize its palette*/
|
|
|
|
lv_obj_t * canvas = lv_canvas_create(lv_scr_act());
|
2023-02-20 20:50:58 +01:00
|
|
|
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_NATIVE);
|
2022-11-21 23:08:32 +01:00
|
|
|
lv_canvas_fill_bg(canvas, lv_color_hex3(0xccc), LV_OPA_COVER);
|
|
|
|
lv_obj_center(canvas);
|
|
|
|
|
2023-07-05 13:05:19 +02:00
|
|
|
lv_layer_t layer;
|
|
|
|
lv_canvas_init_layer(canvas, &layer);
|
|
|
|
|
2022-11-21 23:08:32 +01:00
|
|
|
lv_draw_label_dsc_t dsc;
|
|
|
|
lv_draw_label_dsc_init(&dsc);
|
|
|
|
dsc.color = lv_palette_main(LV_PALETTE_RED);
|
|
|
|
dsc.font = &lv_font_montserrat_18;
|
|
|
|
dsc.decor = LV_TEXT_DECOR_UNDERLINE;
|
2023-07-05 13:05:19 +02:00
|
|
|
dsc.text = "Hello";
|
|
|
|
|
|
|
|
lv_area_t coords = {10, 10, 30, 60};
|
|
|
|
|
|
|
|
lv_draw_label(&layer, &dsc, &coords);
|
|
|
|
|
|
|
|
lv_canvas_finish_layer(canvas, &layer);
|
2022-11-21 23:08:32 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|