标签:blue LV style set lv arc 7.7 lvgl
ARC样式修改线条颜色
定义背景样式
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()函数,并运行,运行效果图如下
标签:blue,LV,style,set,lv,arc,7.7,lvgl 来源: https://blog.csdn.net/mygod2008ok/article/details/110304367
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。