您当前的位置: 首页 > 

仙剑情缘

暂无认证

  • 0浏览

    0关注

    333博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

LVGL V8之Line styles

仙剑情缘 发布时间:2021-08-16 07:05:56 ,浏览量:0

创建style
  • 初时化style
    static lv_style_t style;
    lv_style_init(&style);
  • 设置线的颜色为灰色
 lv_style_set_line_color(&style, lv_palette_main(LV_PALETTE_GREY));
  • 设置线宽为8
 lv_style_set_line_width(&style, 8);
  • 设置线端倒圆角
   lv_style_set_line_rounded(&style, true);
  • 创建obj对象
lv_obj_t* obj = lv_line_create(lv_scr_act());
  • obj对象加入style
lv_obj_add_style(obj, &style, 0);
  • 定义3个坐标点
  static lv_point_t p[] = { {10, 30}, {30, 50}, {100, 0} };
  • obj对角上绘制线条
  lv_line_set_points(obj, p, 3);
  • 居中显示
  lv_obj_center(obj);
完整代码,仅供参考
static void lv_example_style_9(void)
{
    static lv_style_t style;
    lv_style_init(&style);
    lv_style_set_line_color(&style, lv_palette_main(LV_PALETTE_GREY));
    lv_style_set_line_width(&style, 8);
    lv_style_set_line_rounded(&style, true);
    /*Create an object with the new style*/
    lv_obj_t* obj = lv_line_create(lv_scr_act());
    lv_obj_add_style(obj, &style, 0);
    static lv_point_t p[] = { {10, 30}, {30, 50}, {100, 0} };
    lv_line_set_points(obj, p, 3);
    lv_obj_center(obj);


}
调用lv_example_style_9运行效果

在这里插入图片描述

  • 修改线条style颜色为红色
lv_style_set_line_color(&style, lv_palette_main(LV_PALETTE_RED));
  • 效果图 在这里插入图片描述
  • 修改线端不导圆角
  lv_style_set_line_rounded(&style, false);
  • 效果图 在这里插入图片描述
关注
打赏
1658017818
查看更多评论
立即登录/注册

微信扫码登录

0.0380s