当前位置:网站首页>LVGL 8.2 Line

LVGL 8.2 Line

2022-07-04 14:35:00 Fairy sword love

Simple Line


{
    
    /*Create an array for the points of the line*/
    static lv_point_t line_points[] = {
     {
    5, 5}, {
    70, 70}, {
    120, 10}, {
    180, 60}, {
    240,10} };  // 5 Coordinate values of points 
 

    /*Create style*/
    static lv_style_t style_line;
    lv_style_init(&style_line);
    lv_style_set_line_width(&style_line, 8);  //  Set the line width 
    lv_style_set_line_color(&style_line, lv_palette_main(LV_PALETTE_BLUE));// Set the line color to blue 
    lv_style_set_line_rounded(&style_line, true); //  Enable line fillet function 
    /*Create a line and apply the new style*/
    lv_obj_t* line1;
    line1 = lv_line_create(lv_scr_act());  //  Create a line object 
    lv_line_set_points(line1, line_points, 5); //  Set the number of line data points 
    lv_obj_add_style(line1, &style_line, 0); //  Line addition style
    lv_obj_center(line1);  //  centered 
}

Running effect

 Insert picture description here

  • Change the line color to red
 lv_style_set_line_color(&style_line, lv_palette_main(LV_PALETTE_RED));
  • Running effect
     Insert picture description here
  • Turn off the fillet function
 lv_style_set_line_rounded(&style_line, false);

 Insert picture description here

  • Change the line width to 1
lv_style_set_line_width(&style_line, 1);
  • Running effect
     Insert picture description here
原网站

版权声明
本文为[Fairy sword love]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/185/202207041306577828.html