Drawing lines (right now) is designed to take an array of points, and associate them with a line object.
If I want to draw a line which is made up of 30K points, I have to create an array of 30K points!
This consumes too much memory needlessly, and not efficient at all.
Right now, if I want to draw two lines, I have to create an array of four points.
Here is an example:
static lv_style_t style_line;
lv_style_init(&style_line);
lv_style_set_line_width(&style_line, 1);
lv_style_set_line_color(&style_line, lv_palette_main(LV_PALETTE_BLUE));
lv_style_set_line_rounded(&style_line, true);
lv_obj_t * line1;
line1 = lv_line_create(lv_scr_act());
lv_obj_add_style(line1, &style_line, 0);
// The followings will draw two lines correctly
static lv_point_t line_points[4];
line_points[0] = (lv_point_t){100,30};
line_points[1] = (lv_point_t){100,100};
lv_line_set_points(line1, line_points, 2);
line_points[2] = (lv_point_t){100,100};
line_points[3] = (lv_point_t){400,100};
lv_line_set_points(line1, line_points, 4);
// But, the following will draw only one line(the last one)
static lv_point_t line_points[2];
line_points[0] = (lv_point_t){100,30};
line_points[1] = (lv_point_t){100,100};
lv_line_set_points(line1, line_points, 2);
line_points[0] = (lv_point_t){100,100};
line_points[1] = (lv_point_t){400,100};
lv_line_set_points(line1, line_points, 4);
Why can’t lv_line_set_points() use “line1” to draw the two separate lines above?
So, just draws line connecting the two points provided, and forget about previous lines/points.
This way I always declare static lv_point_t line_points[2]; instead of static lv_point_t line_points[4]; or worse: static lv_point_t line_points[30000];
Don’t worry about what happens if user scrolls, I can have loop to re-draw.
In Windows I remember they used to have two wonderful methods: moveto(x1,y1), lineto(x2,y2), and no “overhead” arrays are involved.
I wish lvgl have something like that.