单色显示还能有抗锯齿效果?楼上这个模拟效果不对吧
大佬眼光犀利,确实那个地方一开始确实没改妥。
]]>谢谢楼主的代码
]]>//创建一个屏幕对象
lv_obj_t* scr = lv_obj_create(lv_scr_act());
lv_obj_set_size(scr, 390, 390);
lv_obj_set_style_bg_color(scr, lv_color_white(), LV_PART_MAIN);
lv_obj_set_style_border_color(scr, lv_color_black(), LV_PART_MAIN);
//创建一个arc对象
lv_obj_t* arc_progress = lv_arc_create(scr);
//背景设置
static lv_style_t style_bg;
lv_style_init(&style_bg);
//lv_style_reset(&style_bg);
lv_style_set_bg_color(&style_bg,lv_color_make(0x00, 0x00, 0xff));//设置背景颜色
lv_style_set_bg_opa(&style_bg, LV_OPA_COVER);//设置背景透明度
lv_style_set_bg_grad_color(&style_bg,lv_color_make(0x24, 0xf9, 0xcf));//设置渐变颜色
lv_style_set_bg_grad_dir(&style_bg, LV_GRAD_DIR_VER);//设置渐变方向
lv_style_set_border_opa(&style_bg, LV_OPA_COVER);//设置边框透明度;
lv_style_set_border_width(&style_bg, 3);//设置边框宽度
lv_style_set_border_color(&style_bg, lv_color_make(0, 255, 0));//设置边框颜色
lv_obj_set_style_arc_rounded(arc_progress, true, LV_PART_INDICATOR);
//enum lv_arc_draw_part_type_t
lv_obj_add_style(arc_progress, &style_bg, LV_PART_MAIN);//设置背景样式
lv_obj_set_style_arc_width(arc_progress, 40, LV_PART_MAIN);//设置背景ARC宽度
lv_style_set_arc_color(&style_bg, lv_color_make(255, 0, 0));//设置ARC背景颜色
//去掉圆点
lv_obj_remove_style(arc_progress, NULL, LV_PART_KNOB);
static lv_style_t arc_style_ind;
//lv_style_reset(&style_blue);
lv_style_init(&arc_style_ind);
lv_style_set_arc_color(&arc_style_ind, lv_color_make(255, 255, 0));
lv_obj_set_style_arc_width(arc_progress, 60, LV_PART_INDICATOR);//设置前景ARC宽度
lv_obj_add_style(arc_progress, &arc_style_ind, LV_PART_INDICATOR);//设置Indicator样式
lv_arc_set_bg_angles(arc_progress, 0, 360);
lv_obj_align(arc_progress, LV_ALIGN_CENTER, 0, 0);
lv_arc_set_angles(arc_progress, 0, 270);
lv_obj_set_size(arc_progress, 300, 300);
测试效果如下:
二、ARC测试代码(单色主题)
打开lv_conf.h,将宏定义LV_COLOR_DEPTH设为1
lv_theme_t* th;
lv_disp_t *lv_disp;
lv_disp = lv_disp_get_default();
lv_disp_set_bg_color(lv_disp, lv_color_white());
th = lv_theme_mono_init(lv_disp, false, LV_FONT_DEFAULT);
lv_disp_set_theme(lv_disp, th);
//创建一个屏幕对象
lv_obj_t* scr = lv_obj_create(lv_scr_act());
lv_obj_set_size(scr, 390, 390);
lv_obj_set_style_bg_color(scr, lv_color_white(), LV_PART_MAIN);
lv_obj_set_style_border_color(scr, lv_color_black(), LV_PART_MAIN);
//创建一个arc对象
lv_obj_t* arc_progress = lv_arc_create(scr);
//背景设置
static lv_style_t style_bg;
lv_style_init(&style_bg);
//lv_style_reset(&style_bg);
lv_style_set_bg_color(&style_bg,lv_color_make(0xff, 0xff, 0xff));//设置背景全白
lv_style_set_bg_opa(&style_bg, LV_OPA_COVER);//设置背景透明度
lv_style_set_bg_grad_color(&style_bg,lv_color_make(0xff, 0xff, 0xff));//设置渐变颜色
lv_style_set_bg_grad_dir(&style_bg, LV_GRAD_DIR_VER);//设置渐变方向
lv_style_set_border_opa(&style_bg, LV_OPA_COVER);//设置边框透明度;
lv_style_set_border_width(&style_bg, 3);//设置边框宽度
lv_style_set_border_color(&style_bg, lv_color_make(0, 0, 0));//设置边框颜色
lv_obj_set_style_arc_rounded(arc_progress, true, LV_PART_INDICATOR);
//enum lv_arc_draw_part_type_t
lv_obj_add_style(arc_progress, &style_bg, LV_PART_MAIN);//设置背景样式
lv_obj_set_style_arc_width(arc_progress, 40, LV_PART_MAIN);//设置背景ARC宽度
lv_style_set_arc_color(&style_bg, lv_color_make(255, 0xff, 0xff));//设置ARC背景颜色
//去掉圆点
lv_obj_remove_style(arc_progress, NULL, LV_PART_KNOB);
static lv_style_t arc_style_ind;
//lv_style_reset(&style_blue);
lv_style_init(&arc_style_ind);
lv_style_set_arc_color(&arc_style_ind, lv_color_make(0, 0, 0));
lv_obj_set_style_arc_width(arc_progress, 60, LV_PART_INDICATOR);//设置前景ARC宽度
lv_obj_add_style(arc_progress, &arc_style_ind, LV_PART_INDICATOR);//设置Indicator样式
lv_arc_set_bg_angles(arc_progress, 0, 360);
lv_obj_align(arc_progress, LV_ALIGN_CENTER, 0, 0);
lv_arc_set_angles(arc_progress, 0, 270);
lv_obj_set_size(arc_progress, 300, 300);
效果如下:
对比如下:
]]>