From 60148c5c73acc6ce7f340840c9e202677c2211ba Mon Sep 17 00:00:00 2001 From: TridentTD Date: Tue, 5 Nov 2019 17:40:02 +0700 Subject: [PATCH] move round-ending from lv_arc.c to lv_draw_arc.c --- src/lv_draw/lv_draw_arc.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/lv_draw/lv_draw_arc.c b/src/lv_draw/lv_draw_arc.c index 7b10df6f8..3590b6ff0 100644 --- a/src/lv_draw/lv_draw_arc.c +++ b/src/lv_draw/lv_draw_arc.c @@ -69,8 +69,34 @@ void lv_draw_arc(lv_coord_t center_x, lv_coord_t center_y, uint16_t radius, cons lv_draw_mask_remove_id(mask_angle_id); + // draw rounded-ending if(style->line.rounded) { - /*TODO*/ + circle_style.body.main_color = style->line.color; + circle_style.body.grad_color = style->line.color; + circle_style.body.opa = LV_OPA_COVER; + circle_style.body.border.width = 0; + + lv_coord_t thick_half = style->line.width / 2; + lv_coord_t cir_x = ((radius - thick_half + 1) * lv_trigo_sin(90 - start_angle) >> LV_TRIGO_SHIFT); + lv_coord_t cir_y = ((radius - thick_half + 1) * lv_trigo_sin(start_angle) >> LV_TRIGO_SHIFT); + + lv_area_t round_area; + round_area.x1 = cir_x + center_x - thick_half + 1; + round_area.y1 = cir_y + center_y - thick_half + 1; + round_area.x2 = cir_x + center_x + thick_half; + round_area.y2 = cir_y + center_y + thick_half; + + lv_draw_rect(&round_area, clip_area, &circle_style, LV_OPA_COVER); + + cir_x = ((radius - thick_half + 1) * lv_trigo_sin(90 - end_angle) >> LV_TRIGO_SHIFT); + cir_y = ((radius - thick_half + 1) * lv_trigo_sin(end_angle) >> LV_TRIGO_SHIFT); + + round_area.x1 = cir_x + center_x - thick_half + 1; + round_area.y1 = cir_y + center_y - thick_half + 1; + round_area.x2 = cir_x + center_x + thick_half; + round_area.y2 = cir_y + center_y + thick_half; + + lv_draw_rect(&round_area, clip_area, &circle_style, LV_OPA_COVER); } }