Update LVGL to v9.1.0
This commit is contained in:
@@ -1,13 +1,53 @@
|
||||
|
||||
Drawing on the Canvas and rotate
|
||||
""""""""""""""""""""""""""""""""""
|
||||
--------------------------------
|
||||
|
||||
.. lv_example:: widgets/canvas/lv_example_canvas_1
|
||||
:language: c
|
||||
|
||||
Transparent Canvas with chroma keying
|
||||
""""""""""""""""""""""""""""""""""""""
|
||||
-------------------------------------
|
||||
|
||||
.. lv_example:: widgets/canvas/lv_example_canvas_2
|
||||
:language: c
|
||||
|
||||
|
||||
Draw a rectangle to the canvas
|
||||
------------------------------
|
||||
|
||||
.. lv_example:: widgets/canvas/lv_example_canvas_3
|
||||
:language: c
|
||||
|
||||
|
||||
Draw a label to the canvas
|
||||
--------------------------
|
||||
|
||||
.. lv_example:: widgets/canvas/lv_example_canvas_4
|
||||
:language: c
|
||||
|
||||
|
||||
Draw an arc to the canvas
|
||||
-------------------------
|
||||
|
||||
.. lv_example:: widgets/canvas/lv_example_canvas_5
|
||||
:language: c
|
||||
|
||||
|
||||
Draw an image to the canvas
|
||||
---------------------------
|
||||
|
||||
.. lv_example:: widgets/canvas/lv_example_canvas_6
|
||||
:language: c
|
||||
|
||||
|
||||
Draw a line to the canvas
|
||||
-------------------------
|
||||
|
||||
.. lv_example:: widgets/canvas/lv_example_canvas_7
|
||||
:language: c
|
||||
|
||||
Draw a vector graphic to the canvas
|
||||
-------------------------
|
||||
|
||||
.. lv_example:: widgets/canvas/lv_example_canvas_8
|
||||
:language: c
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_CANVAS && LV_BUILD_EXAMPLES
|
||||
|
||||
|
||||
#define CANVAS_WIDTH 200
|
||||
#define CANVAS_HEIGHT 150
|
||||
|
||||
@@ -11,43 +10,66 @@ void lv_example_canvas_1(void)
|
||||
lv_draw_rect_dsc_init(&rect_dsc);
|
||||
rect_dsc.radius = 10;
|
||||
rect_dsc.bg_opa = LV_OPA_COVER;
|
||||
rect_dsc.bg_grad.dir = LV_GRAD_DIR_HOR;
|
||||
rect_dsc.bg_grad.dir = LV_GRAD_DIR_VER;
|
||||
rect_dsc.bg_grad.stops[0].color = lv_palette_main(LV_PALETTE_RED);
|
||||
rect_dsc.bg_grad.stops[0].opa = LV_OPA_100;
|
||||
rect_dsc.bg_grad.stops[1].color = lv_palette_main(LV_PALETTE_BLUE);
|
||||
rect_dsc.bg_grad.stops[1].opa = LV_OPA_50;
|
||||
rect_dsc.border_width = 2;
|
||||
rect_dsc.border_opa = LV_OPA_90;
|
||||
rect_dsc.border_color = lv_color_white();
|
||||
rect_dsc.shadow_width = 5;
|
||||
rect_dsc.shadow_ofs_x = 5;
|
||||
rect_dsc.shadow_ofs_y = 5;
|
||||
rect_dsc.shadow_offset_x = 5;
|
||||
rect_dsc.shadow_offset_y = 5;
|
||||
|
||||
lv_draw_label_dsc_t label_dsc;
|
||||
lv_draw_label_dsc_init(&label_dsc);
|
||||
label_dsc.color = lv_palette_main(LV_PALETTE_ORANGE);
|
||||
label_dsc.text = "Some text on text canvas";
|
||||
/*Create a buffer for the canvas*/
|
||||
LV_DRAW_BUF_DEFINE(draw_buf_16bpp, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_RGB565);
|
||||
|
||||
static lv_color_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT)];
|
||||
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_scr_act());
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_IMG_CF_TRUE_COLOR);
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_screen_active());
|
||||
lv_canvas_set_draw_buf(canvas, &draw_buf_16bpp);
|
||||
lv_obj_center(canvas);
|
||||
lv_canvas_fill_bg(canvas, lv_palette_lighten(LV_PALETTE_GREY, 3), LV_OPA_COVER);
|
||||
|
||||
lv_canvas_draw_rect(canvas, 70, 60, 100, 70, &rect_dsc);
|
||||
lv_layer_t layer;
|
||||
lv_canvas_init_layer(canvas, &layer);
|
||||
|
||||
lv_canvas_draw_text(canvas, 40, 20, 100, &label_dsc, "Some text on text canvas");
|
||||
lv_area_t coords_rect = {30, 20, 100, 70};
|
||||
lv_draw_rect(&layer, &rect_dsc, &coords_rect);
|
||||
|
||||
lv_area_t coords_text = {40, 80, 100, 120};
|
||||
lv_draw_label(&layer, &label_dsc, &coords_text);
|
||||
|
||||
lv_canvas_finish_layer(canvas, &layer);
|
||||
|
||||
/*Test the rotation. It requires another buffer where the original image is stored.
|
||||
*So copy the current image to buffer and rotate it to the canvas*/
|
||||
static lv_color_t cbuf_tmp[CANVAS_WIDTH * CANVAS_HEIGHT];
|
||||
memcpy(cbuf_tmp, cbuf, sizeof(cbuf_tmp));
|
||||
lv_img_dsc_t img;
|
||||
img.data = (void *)cbuf_tmp;
|
||||
img.header.cf = LV_IMG_CF_TRUE_COLOR;
|
||||
img.header.w = CANVAS_WIDTH;
|
||||
img.header.h = CANVAS_HEIGHT;
|
||||
*So use previous canvas as image and rotate it to the new canvas*/
|
||||
LV_DRAW_BUF_DEFINE(draw_buf_32bpp, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_ARGB8888);
|
||||
/*Create a canvas and initialize its palette*/
|
||||
canvas = lv_canvas_create(lv_screen_active());
|
||||
lv_canvas_set_draw_buf(canvas, &draw_buf_32bpp);
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex3(0xccc), LV_OPA_COVER);
|
||||
lv_obj_center(canvas);
|
||||
|
||||
lv_canvas_fill_bg(canvas, lv_palette_lighten(LV_PALETTE_GREY, 3), LV_OPA_COVER);
|
||||
lv_canvas_transform(canvas, &img, 120, LV_IMG_ZOOM_NONE, 0, 0, CANVAS_WIDTH / 2, CANVAS_HEIGHT / 2, true);
|
||||
lv_canvas_fill_bg(canvas, lv_palette_lighten(LV_PALETTE_GREY, 1), LV_OPA_COVER);
|
||||
|
||||
lv_canvas_init_layer(canvas, &layer);
|
||||
lv_image_dsc_t img;
|
||||
lv_draw_buf_to_image(&draw_buf_16bpp, &img);
|
||||
lv_draw_image_dsc_t img_dsc;
|
||||
lv_draw_image_dsc_init(&img_dsc);
|
||||
img_dsc.rotation = 120;
|
||||
img_dsc.src = &img;
|
||||
img_dsc.pivot.x = CANVAS_WIDTH / 2;
|
||||
img_dsc.pivot.y = CANVAS_HEIGHT / 2;
|
||||
|
||||
lv_area_t coords_img = {0, 0, CANVAS_WIDTH - 1, CANVAS_HEIGHT - 1};
|
||||
lv_draw_image(&layer, &img_dsc, &coords_img);
|
||||
|
||||
lv_canvas_finish_layer(canvas, &layer);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
_CANVAS_WIDTH = 200
|
||||
_CANVAS_HEIGHT = 150
|
||||
LV_IMG_ZOOM_NONE = 256
|
||||
|
||||
rect_dsc = lv.draw_rect_dsc_t()
|
||||
rect_dsc.init()
|
||||
rect_dsc.radius = 10
|
||||
rect_dsc.bg_opa = lv.OPA.COVER
|
||||
rect_dsc.bg_grad.dir = lv.GRAD_DIR.HOR
|
||||
rect_dsc.bg_grad.stops[0].color = lv.palette_main(lv.PALETTE.RED)
|
||||
rect_dsc.bg_grad.stops[1].color = lv.palette_main(lv.PALETTE.BLUE)
|
||||
rect_dsc.border_width = 2
|
||||
rect_dsc.border_opa = lv.OPA._90
|
||||
rect_dsc.border_color = lv.color_white()
|
||||
rect_dsc.shadow_width = 5
|
||||
rect_dsc.shadow_ofs_x = 5
|
||||
rect_dsc.shadow_ofs_y = 5
|
||||
|
||||
label_dsc = lv.draw_label_dsc_t()
|
||||
label_dsc.init()
|
||||
label_dsc.color = lv.palette_main(lv.PALETTE.YELLOW)
|
||||
|
||||
cbuf = bytearray(_CANVAS_WIDTH * _CANVAS_HEIGHT * 4)
|
||||
|
||||
canvas = lv.canvas(lv.scr_act())
|
||||
canvas.set_buffer(cbuf, _CANVAS_WIDTH, _CANVAS_HEIGHT, lv.img.CF.TRUE_COLOR)
|
||||
canvas.center()
|
||||
canvas.fill_bg(lv.palette_lighten(lv.PALETTE.GREY, 3), lv.OPA.COVER)
|
||||
|
||||
canvas.draw_rect(70, 60, 100, 70, rect_dsc)
|
||||
canvas.draw_text(40, 20, 100, label_dsc, "Some text on text canvas")
|
||||
|
||||
# Test the rotation. It requires another buffer where the original image is stored.
|
||||
# So copy the current image to buffer and rotate it to the canvas
|
||||
|
||||
img = lv.img_dsc_t()
|
||||
img.data = cbuf[:]
|
||||
img.header.cf = lv.img.CF.TRUE_COLOR
|
||||
img.header.w = _CANVAS_WIDTH
|
||||
img.header.h = _CANVAS_HEIGHT
|
||||
|
||||
canvas.fill_bg(lv.palette_lighten(lv.PALETTE.GREY, 3), lv.OPA.COVER)
|
||||
canvas.transform(img, 30, LV_IMG_ZOOM_NONE, 0, 0, _CANVAS_WIDTH // 2, _CANVAS_HEIGHT // 2, True)
|
||||
@@ -1,44 +1,45 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_CANVAS && LV_BUILD_EXAMPLES
|
||||
|
||||
#define CANVAS_WIDTH 50
|
||||
#define CANVAS_HEIGHT 50
|
||||
#define CANVAS_WIDTH 80
|
||||
#define CANVAS_HEIGHT 40
|
||||
|
||||
/**
|
||||
* Create a transparent canvas with Chroma keying and indexed color format (palette).
|
||||
* Create a transparent canvas with transparency
|
||||
*/
|
||||
void lv_example_canvas_2(void)
|
||||
{
|
||||
/*Create a button to better see the transparency*/
|
||||
lv_btn_create(lv_scr_act());
|
||||
lv_obj_set_style_bg_color(lv_screen_active(), lv_palette_lighten(LV_PALETTE_RED, 5), 0);
|
||||
|
||||
/*Create a buffer for the canvas*/
|
||||
static lv_color_t cbuf[LV_CANVAS_BUF_SIZE_INDEXED_1BIT(CANVAS_WIDTH, CANVAS_HEIGHT)];
|
||||
|
||||
LV_DRAW_BUF_DEFINE(draw_buf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_ARGB8888);
|
||||
/*Create a canvas and initialize its palette*/
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_scr_act());
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_IMG_CF_INDEXED_1BIT);
|
||||
lv_canvas_set_palette(canvas, 0, LV_COLOR_CHROMA_KEY);
|
||||
lv_canvas_set_palette(canvas, 1, lv_palette_main(LV_PALETTE_RED));
|
||||
|
||||
/*Create colors with the indices of the palette*/
|
||||
lv_color_t c0;
|
||||
lv_color_t c1;
|
||||
|
||||
c0.full = 0;
|
||||
c1.full = 1;
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_screen_active());
|
||||
lv_canvas_set_draw_buf(canvas, &draw_buf);
|
||||
lv_obj_center(canvas);
|
||||
|
||||
/*Red background (There is no dedicated alpha channel in indexed images so LV_OPA_COVER is ignored)*/
|
||||
lv_canvas_fill_bg(canvas, c1, LV_OPA_COVER);
|
||||
lv_canvas_fill_bg(canvas, lv_palette_main(LV_PALETTE_BLUE), LV_OPA_COVER);
|
||||
|
||||
/*Create hole on the canvas*/
|
||||
uint32_t x;
|
||||
uint32_t y;
|
||||
for(y = 10; y < 30; y++) {
|
||||
for(x = 5; x < 20; x++) {
|
||||
lv_canvas_set_px_color(canvas, x, y, c0);
|
||||
for(y = 10; y < 20; y++) {
|
||||
for(x = 5; x < 75; x++) {
|
||||
lv_canvas_set_px(canvas, x, y, lv_palette_main(LV_PALETTE_BLUE), LV_OPA_50);
|
||||
}
|
||||
}
|
||||
|
||||
for(y = 20; y < 30; y++) {
|
||||
for(x = 5; x < 75; x++) {
|
||||
lv_canvas_set_px(canvas, x, y, lv_palette_main(LV_PALETTE_BLUE), LV_OPA_20);
|
||||
}
|
||||
}
|
||||
|
||||
for(y = 30; y < 40; y++) {
|
||||
for(x = 5; x < 75; x++) {
|
||||
lv_canvas_set_px(canvas, x, y, lv_palette_main(LV_PALETTE_BLUE), LV_OPA_0);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
CANVAS_WIDTH = 50
|
||||
CANVAS_HEIGHT = 50
|
||||
LV_COLOR_CHROMA_KEY = lv.color_hex(0x00ff00)
|
||||
|
||||
def LV_IMG_BUF_SIZE_ALPHA_1BIT(w, h):
|
||||
return int(((w / 8) + 1) * h)
|
||||
|
||||
def LV_IMG_BUF_SIZE_INDEXED_1BIT(w, h):
|
||||
return LV_IMG_BUF_SIZE_ALPHA_1BIT(w, h) + 4 * 2
|
||||
|
||||
def LV_CANVAS_BUF_SIZE_INDEXED_1BIT(w, h):
|
||||
return LV_IMG_BUF_SIZE_INDEXED_1BIT(w, h)
|
||||
|
||||
#
|
||||
# Create a transparent canvas with Chroma keying and indexed color format (palette).
|
||||
#
|
||||
|
||||
# Create a button to better see the transparency
|
||||
btn=lv.btn(lv.scr_act())
|
||||
|
||||
# Create a buffer for the canvas
|
||||
cbuf= bytearray(LV_CANVAS_BUF_SIZE_INDEXED_1BIT(CANVAS_WIDTH, CANVAS_HEIGHT))
|
||||
|
||||
# Create a canvas and initialize its palette
|
||||
canvas = lv.canvas(lv.scr_act())
|
||||
canvas.set_buffer(cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, lv.img.CF.INDEXED_1BIT)
|
||||
canvas.set_palette(0, LV_COLOR_CHROMA_KEY)
|
||||
canvas.set_palette(1, lv.palette_main(lv.PALETTE.RED))
|
||||
|
||||
# Create colors with the indices of the palette
|
||||
c0 = lv.color_t()
|
||||
c1 = lv.color_t()
|
||||
|
||||
c0.full = 0
|
||||
c1.full = 1
|
||||
|
||||
# Red background (There is no dedicated alpha channel in indexed images so LV_OPA_COVER is ignored)
|
||||
canvas.fill_bg(c1, lv.OPA.COVER)
|
||||
|
||||
# Create hole on the canvas
|
||||
for y in range(10,30):
|
||||
for x in range(5,20):
|
||||
canvas.set_px(x, y, c0)
|
||||
@@ -0,0 +1,43 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_CANVAS && LV_BUILD_EXAMPLES
|
||||
|
||||
#define CANVAS_WIDTH 50
|
||||
#define CANVAS_HEIGHT 50
|
||||
|
||||
/**
|
||||
* Draw a rectangle to the canvas
|
||||
*/
|
||||
void lv_example_canvas_3(void)
|
||||
{
|
||||
/*Create a buffer for the canvas*/
|
||||
LV_DRAW_BUF_DEFINE(draw_buf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_ARGB8888);
|
||||
|
||||
/*Create a canvas and initialize its palette*/
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_screen_active());
|
||||
lv_canvas_set_draw_buf(canvas, &draw_buf);
|
||||
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex3(0xccc), LV_OPA_COVER);
|
||||
lv_obj_center(canvas);
|
||||
|
||||
lv_layer_t layer;
|
||||
lv_canvas_init_layer(canvas, &layer);
|
||||
|
||||
lv_draw_rect_dsc_t dsc;
|
||||
lv_draw_rect_dsc_init(&dsc);
|
||||
dsc.bg_color = lv_palette_main(LV_PALETTE_RED);
|
||||
dsc.border_color = lv_palette_main(LV_PALETTE_BLUE);
|
||||
dsc.border_width = 3;
|
||||
dsc.outline_color = lv_palette_main(LV_PALETTE_GREEN);
|
||||
dsc.outline_width = 2;
|
||||
dsc.outline_pad = 2;
|
||||
dsc.outline_opa = LV_OPA_50;
|
||||
dsc.radius = 5;
|
||||
dsc.border_width = 3;
|
||||
|
||||
lv_area_t coords = {10, 10, 40, 30};
|
||||
|
||||
lv_draw_rect(&layer, &dsc, &coords);
|
||||
|
||||
lv_canvas_finish_layer(canvas, &layer);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,38 @@
|
||||
#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*/
|
||||
LV_DRAW_BUF_DEFINE(draw_buf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_ARGB8888);
|
||||
|
||||
/*Create a canvas and initialize its palette*/
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_screen_active());
|
||||
lv_canvas_set_draw_buf(canvas, &draw_buf);
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex3(0xccc), LV_OPA_COVER);
|
||||
lv_obj_center(canvas);
|
||||
|
||||
lv_layer_t layer;
|
||||
lv_canvas_init_layer(canvas, &layer);
|
||||
|
||||
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;
|
||||
dsc.text = "Hello";
|
||||
|
||||
lv_area_t coords = {10, 10, 30, 60};
|
||||
|
||||
lv_draw_label(&layer, &dsc, &coords);
|
||||
|
||||
lv_canvas_finish_layer(canvas, &layer);
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_CANVAS && LV_BUILD_EXAMPLES
|
||||
|
||||
#define CANVAS_WIDTH 50
|
||||
#define CANVAS_HEIGHT 50
|
||||
|
||||
/**
|
||||
* Draw an arc to the canvas
|
||||
*/
|
||||
void lv_example_canvas_5(void)
|
||||
{
|
||||
/*Create a buffer for the canvas*/
|
||||
LV_DRAW_BUF_DEFINE(draw_buf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_ARGB8888);
|
||||
|
||||
/*Create a canvas and initialize its palette*/
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_screen_active());
|
||||
lv_canvas_set_draw_buf(canvas, &draw_buf);
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex3(0xccc), LV_OPA_COVER);
|
||||
lv_obj_center(canvas);
|
||||
|
||||
lv_layer_t layer;
|
||||
lv_canvas_init_layer(canvas, &layer);
|
||||
|
||||
lv_draw_arc_dsc_t dsc;
|
||||
lv_draw_arc_dsc_init(&dsc);
|
||||
dsc.color = lv_palette_main(LV_PALETTE_RED);
|
||||
dsc.width = 5;
|
||||
dsc.center.x = 25;
|
||||
dsc.center.y = 25;
|
||||
dsc.width = 10;
|
||||
dsc.radius = 15;
|
||||
dsc.start_angle = 0;
|
||||
dsc.end_angle = 220;
|
||||
|
||||
lv_draw_arc(&layer, &dsc);
|
||||
|
||||
lv_canvas_finish_layer(canvas, &layer);
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_CANVAS && LV_BUILD_EXAMPLES
|
||||
|
||||
#define CANVAS_WIDTH 50
|
||||
#define CANVAS_HEIGHT 50
|
||||
|
||||
/**
|
||||
* Draw an image to the canvas
|
||||
*/
|
||||
void lv_example_canvas_6(void)
|
||||
{
|
||||
/*Create a buffer for the canvas*/
|
||||
static uint8_t cbuf[LV_CANVAS_BUF_SIZE(CANVAS_WIDTH, CANVAS_HEIGHT, 32, LV_DRAW_BUF_STRIDE_ALIGN)];
|
||||
|
||||
/*Create a canvas and initialize its palette*/
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_screen_active());
|
||||
lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_ARGB8888);
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex3(0xccc), LV_OPA_COVER);
|
||||
lv_obj_center(canvas);
|
||||
|
||||
lv_layer_t layer;
|
||||
lv_canvas_init_layer(canvas, &layer);
|
||||
|
||||
LV_IMAGE_DECLARE(img_star);
|
||||
lv_draw_image_dsc_t dsc;
|
||||
lv_draw_image_dsc_init(&dsc);
|
||||
dsc.src = &img_star;
|
||||
|
||||
lv_area_t coords = {10, 10, 10 + img_star.header.w - 1, 10 + img_star.header.h - 1};
|
||||
|
||||
lv_draw_image(&layer, &dsc, &coords);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,39 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_CANVAS&& LV_BUILD_EXAMPLES
|
||||
|
||||
#define CANVAS_WIDTH 50
|
||||
#define CANVAS_HEIGHT 50
|
||||
|
||||
/**
|
||||
* Draw a line to the canvas
|
||||
*/
|
||||
void lv_example_canvas_7(void)
|
||||
{
|
||||
/*Create a buffer for the canvas*/
|
||||
LV_DRAW_BUF_DEFINE(draw_buf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_ARGB8888);
|
||||
|
||||
/*Create a canvas and initialize its palette*/
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_screen_active());
|
||||
lv_canvas_set_draw_buf(canvas, &draw_buf);
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex3(0xccc), LV_OPA_COVER);
|
||||
lv_obj_center(canvas);
|
||||
|
||||
lv_layer_t layer;
|
||||
lv_canvas_init_layer(canvas, &layer);
|
||||
|
||||
lv_draw_line_dsc_t dsc;
|
||||
lv_draw_line_dsc_init(&dsc);
|
||||
dsc.color = lv_palette_main(LV_PALETTE_RED);
|
||||
dsc.width = 4;
|
||||
dsc.round_end = 1;
|
||||
dsc.round_start = 1;
|
||||
dsc.p1.x = 15;
|
||||
dsc.p1.y = 15;
|
||||
dsc.p2.x = 35;
|
||||
dsc.p2.y = 10;
|
||||
lv_draw_line(&layer, &dsc);
|
||||
|
||||
lv_canvas_finish_layer(canvas, &layer);
|
||||
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,56 @@
|
||||
#include "../../lv_examples.h"
|
||||
#if LV_USE_CANVAS && LV_BUILD_EXAMPLES
|
||||
|
||||
#if LV_USE_VECTOR_GRAPHIC
|
||||
|
||||
#define CANVAS_WIDTH 150
|
||||
#define CANVAS_HEIGHT 150
|
||||
|
||||
/**
|
||||
* Draw a path to the canvas
|
||||
*/
|
||||
void lv_example_canvas_8(void)
|
||||
{
|
||||
/*Create a buffer for the canvas*/
|
||||
LV_DRAW_BUF_DEFINE(draw_buf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_COLOR_FORMAT_ARGB8888);
|
||||
|
||||
/*Create a canvas and initialize its palette*/
|
||||
lv_obj_t * canvas = lv_canvas_create(lv_screen_active());
|
||||
lv_canvas_set_draw_buf(canvas, &draw_buf);
|
||||
lv_canvas_fill_bg(canvas, lv_color_hex3(0xccc), LV_OPA_COVER);
|
||||
lv_obj_center(canvas);
|
||||
|
||||
lv_layer_t layer;
|
||||
lv_canvas_init_layer(canvas, &layer);
|
||||
|
||||
lv_vector_dsc_t * dsc = lv_vector_dsc_create(&layer);
|
||||
lv_vector_path_t * path = lv_vector_path_create(LV_VECTOR_PATH_QUALITY_MEDIUM);
|
||||
|
||||
lv_fpoint_t pts[] = {{10, 10}, {130, 130}, {10, 130}};
|
||||
lv_vector_path_move_to(path, &pts[0]);
|
||||
lv_vector_path_line_to(path, &pts[1]);
|
||||
lv_vector_path_line_to(path, &pts[2]);
|
||||
lv_vector_path_close(path);
|
||||
|
||||
lv_vector_dsc_set_fill_color(dsc, lv_color_make(0x00, 0x80, 0xff));
|
||||
lv_vector_dsc_add_path(dsc, path);
|
||||
|
||||
lv_draw_vector(dsc);
|
||||
lv_vector_path_delete(path);
|
||||
lv_vector_dsc_delete(dsc);
|
||||
|
||||
lv_canvas_finish_layer(canvas, &layer);
|
||||
}
|
||||
#else
|
||||
|
||||
void lv_example_canvas_8(void)
|
||||
{
|
||||
/*fallback for online examples*/
|
||||
lv_obj_t * label = lv_label_create(lv_screen_active());
|
||||
lv_label_set_text(label, "Vector graphics is not enabled");
|
||||
lv_obj_center(label);
|
||||
}
|
||||
|
||||
#endif /*LV_USE_VECTOR_GRAPHIC*/
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user