您当前的位置: 首页 >  ar

仙剑情缘

暂无认证

  • 0浏览

    0关注

    333博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

lvgl 7.7.2 arc样式

仙剑情缘 发布时间:2020-11-29 08:56:35 ,浏览量:0

ARC样式修改线条颜色
    • 定义背景样式
    • 定义线条样式
    • 绘制并加载黑色屏幕
    • 绘制ARC
    • 完整的绘制ARC样式函数如下
    • 在main函数中调用arc_test()函数,并运行,运行效果图如下

定义背景样式
     static lv_style_t style_bg;
     lv_style_reset(&style_bg);
     lv_style_init(&style_bg);
     lv_style_set_bg_opa(&style_bg, LV_STATE_DEFAULT, LV_OPA_TRANSP);
     lv_style_set_border_opa(&style_bg, LV_STATE_DEFAULT, LV_OPA_TRANSP);
     lv_style_set_line_color(&style_bg, LV_STATE_DEFAULT, LV_COLOR_MAKE(255, 0, 0));
     lv_style_set_line_width(&style_bg, LV_STATE_DEFAULT, 9);
定义线条样式
     static lv_style_t style_blue;
     lv_style_reset(&style_blue);
     lv_style_init(&style_blue);
     lv_style_set_line_color(&style_blue, LV_STATE_DEFAULT, LV_COLOR_MAKE(0, 0, 255));
     lv_style_set_line_width(&style_blue, LV_STATE_DEFAULT, 9);
绘制并加载黑色屏幕
     lv_obj_t* scr = lv_obj_create(lv_scr_act(), NULL);
     lv_obj_set_size(scr, 390, 390);
     lv_obj_set_style_local_bg_color(scr, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
     lv_obj_set_style_local_border_opa(scr, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
绘制ARC
     /*Create an Arc_blue*/
     lv_obj_t* arc_blue = lv_arc_create(scr, NULL);
     lv_obj_add_style(arc_blue, LV_ARC_PART_BG, &style_bg);
     lv_arc_set_bg_angles(arc_blue, 228, 312);					//clear background arc
     lv_obj_set_size(arc_blue, 380, 380);					//set size of weight
     lv_obj_align(arc_blue, NULL, LV_ALIGN_CENTER, 0, 0);
     lv_arc_set_angles(arc_blue, 228, 270);
     lv_obj_add_style(arc_blue, LV_ARC_PART_BG, &style_bg);
     lv_obj_add_style(arc_blue, LV_ARC_PART_INDIC, &style_blue);
完整的绘制ARC样式函数如下
void arc_test(void)
 {
     //background style
     static lv_style_t style_bg;
     lv_style_reset(&style_bg);
     lv_style_init(&style_bg);
     lv_style_set_bg_opa(&style_bg, LV_STATE_DEFAULT, LV_OPA_TRANSP);
     lv_style_set_border_opa(&style_bg, LV_STATE_DEFAULT, LV_OPA_TRANSP);
     lv_style_set_line_color(&style_bg, LV_STATE_DEFAULT, LV_COLOR_MAKE(255, 0, 0));
     lv_style_set_line_width(&style_bg, LV_STATE_DEFAULT, 9);


     //line style_blue
     static lv_style_t style_blue;
     lv_style_reset(&style_blue);
     lv_style_init(&style_blue);
     lv_style_set_line_color(&style_blue, LV_STATE_DEFAULT, LV_COLOR_MAKE(0, 0, 255));
     lv_style_set_line_width(&style_blue, LV_STATE_DEFAULT, 9);

  

     //draw background
     lv_obj_t* scr = lv_obj_create(lv_scr_act(), NULL);
     lv_obj_set_size(scr, 390, 390);
     lv_obj_set_style_local_bg_color(scr, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK);
     lv_obj_set_style_local_border_opa(scr, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_TRANSP);
     

     /*Create an Arc_blue*/
     lv_obj_t* arc_blue = lv_arc_create(scr, NULL);
     lv_obj_add_style(arc_blue, LV_ARC_PART_BG, &style_bg);
     lv_arc_set_bg_angles(arc_blue, 228, 312);					//clear background arc
     lv_obj_set_size(arc_blue, 380, 380);					//set size of weight
     lv_obj_align(arc_blue, NULL, LV_ALIGN_CENTER, 0, 0);
     lv_arc_set_angles(arc_blue, 228, 270);
     lv_obj_add_style(arc_blue, LV_ARC_PART_BG, &style_bg);
     lv_obj_add_style(arc_blue, LV_ARC_PART_INDIC, &style_blue);
 
 }
在main函数中调用arc_test()函数,并运行,运行效果图如下

效果图

关注
打赏
1658017818
查看更多评论
立即登录/注册

微信扫码登录

0.0394s