line_demo.lua 850 B

12345678910111213141516171819202122
  1. local line_demo = {}
  2. function line_demo.demo()
  3. --Create an array for the points of the line
  4. local line_points = { {5, 5}, {70, 70}, {120, 10}, {180, 60}, {240, 10} };
  5. --Create style
  6. local style_line = lvgl.style_t();
  7. lvgl.style_init(style_line);
  8. lvgl.style_set_line_width(style_line, lvgl.STATE_DEFAULT, 8);
  9. lvgl.style_set_line_color(style_line, lvgl.STATE_DEFAULT, lvgl.color_make(0x00, 0x00, 0xFF));
  10. lvgl.style_set_line_rounded(style_line, lvgl.STATE_DEFAULT, true);
  11. --Create a line and apply the new style
  12. local line1;
  13. line1 = lvgl.line_create(lvgl.scr_act(), nil);
  14. lvgl.line_set_points(line1, line_points, 5); --Set the points
  15. lvgl.obj_add_style(line1, lvgl.LINE_PART_MAIN, style_line); --Set the points
  16. lvgl.obj_align(line1, nil, lvgl.ALIGN_CENTER, 0, 0);
  17. end
  18. return line_demo