LVGL 8.2 Line

133 篇文章 112 订阅

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个点坐标值
 

    /*Create style*/
    static lv_style_t style_line;
    lv_style_init(&style_line);
    lv_style_set_line_width(&style_line, 8);  // 设置线宽
    lv_style_set_line_color(&style_line, lv_palette_main(LV_PALETTE_BLUE));//设置线条颜色为蓝色
    lv_style_set_line_rounded(&style_line, true); // 使能线条圆角功能
    /*Create a line and apply the new style*/
    lv_obj_t* line1;
    line1 = lv_line_create(lv_scr_act());  // 创建线条对象
    lv_line_set_points(line1, line_points, 5); // 设置线条数据点数
    lv_obj_add_style(line1, &style_line, 0); // 线条添加style
    lv_obj_center(line1);  // 居中显示
}

运行效果

在这里插入图片描述

  • 修改线条颜色为红色
 lv_style_set_line_color(&style_line, lv_palette_main(LV_PALETTE_RED));
  • 运行效果
    在这里插入图片描述
  • 关闭圆角功能
 lv_style_set_line_rounded(&style_line, false);

在这里插入图片描述

  • 修改线宽为1
lv_style_set_line_width(&style_line, 1);
  • 运行效果
    在这里插入图片描述
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值