fix(draw_line): use lv_point_precise_t to describe coordinates (#4858)
Signed-off-by: pengyiqiang <pengyiqiang@xiaomi.com> Co-authored-by: pengyiqiang <pengyiqiang@xiaomi.com>
This commit is contained in:
@@ -27,10 +27,10 @@ void lv_example_canvas_7(void)
|
||||
dsc.width = 4;
|
||||
dsc.round_end = 1;
|
||||
dsc.round_start = 1;
|
||||
dsc.p1_x = 15;
|
||||
dsc.p1_y = 15;
|
||||
dsc.p2_x = 35;
|
||||
dsc.p2_y = 10;
|
||||
dsc.p1.x = 15;
|
||||
dsc.p1.y = 15;
|
||||
dsc.p2.x = 35;
|
||||
dsc.p2.y = 10;
|
||||
lv_draw_line(&layer, &dsc);
|
||||
|
||||
lv_canvas_finish_layer(canvas, &layer);
|
||||
|
||||
@@ -23,10 +23,10 @@ dsc.color = lv.palette_main(lv.PALETTE.RED)
|
||||
dsc.width = 4
|
||||
dsc.round_end = 1
|
||||
dsc.round_start = 1
|
||||
dsc.p1_x = 15;
|
||||
dsc.p1_y = 15;
|
||||
dsc.p2_x = 35;
|
||||
dsc.p2_y = 10;
|
||||
dsc.p1.x = 15;
|
||||
dsc.p1.y = 15;
|
||||
dsc.p2.x = 35;
|
||||
dsc.p2.y = 10;
|
||||
|
||||
layer = lv.layer_t()
|
||||
canvas.init_layer(layer);
|
||||
|
||||
@@ -61,17 +61,17 @@ static void add_faded_area(lv_event_t * e)
|
||||
lv_draw_triangle_dsc_t tri_dsc;
|
||||
|
||||
lv_draw_triangle_dsc_init(&tri_dsc);
|
||||
tri_dsc.p[0].x = draw_line_dsc->p1_x;
|
||||
tri_dsc.p[0].y = draw_line_dsc->p1_y;
|
||||
tri_dsc.p[1].x = draw_line_dsc->p2_x;
|
||||
tri_dsc.p[1].y = draw_line_dsc->p2_y;
|
||||
tri_dsc.p[2].x = draw_line_dsc->p1_y < draw_line_dsc->p2_y ? draw_line_dsc->p1_x : draw_line_dsc->p2_x;
|
||||
tri_dsc.p[2].y = LV_MAX(draw_line_dsc->p1_y, draw_line_dsc->p2_y);
|
||||
tri_dsc.p[0].x = draw_line_dsc->p1.x;
|
||||
tri_dsc.p[0].y = draw_line_dsc->p1.y;
|
||||
tri_dsc.p[1].x = draw_line_dsc->p2.x;
|
||||
tri_dsc.p[1].y = draw_line_dsc->p2.y;
|
||||
tri_dsc.p[2].x = draw_line_dsc->p1.y < draw_line_dsc->p2.y ? draw_line_dsc->p1.x : draw_line_dsc->p2.x;
|
||||
tri_dsc.p[2].y = LV_MAX(draw_line_dsc->p1.y, draw_line_dsc->p2.y);
|
||||
tri_dsc.bg_grad.dir = LV_GRAD_DIR_VER;
|
||||
|
||||
int32_t full_h = lv_obj_get_height(obj);
|
||||
int32_t fract_uppter = (int32_t)(LV_MIN(draw_line_dsc->p1_y, draw_line_dsc->p2_y) - obj->coords.y1) * 255 / full_h;
|
||||
int32_t fract_lower = (int32_t)(LV_MAX(draw_line_dsc->p1_y, draw_line_dsc->p2_y) - obj->coords.y1) * 255 / full_h;
|
||||
int32_t fract_uppter = (int32_t)(LV_MIN(draw_line_dsc->p1.y, draw_line_dsc->p2.y) - obj->coords.y1) * 255 / full_h;
|
||||
int32_t fract_lower = (int32_t)(LV_MAX(draw_line_dsc->p1.y, draw_line_dsc->p2.y) - obj->coords.y1) * 255 / full_h;
|
||||
tri_dsc.bg_grad.stops[0].color = ser->color;
|
||||
tri_dsc.bg_grad.stops[0].opa = 255 - fract_uppter;
|
||||
tri_dsc.bg_grad.stops[0].frac = 0;
|
||||
@@ -93,9 +93,9 @@ static void add_faded_area(lv_event_t * e)
|
||||
rect_dsc.bg_grad.stops[1].opa = 0;
|
||||
|
||||
lv_area_t rect_area;
|
||||
rect_area.x1 = (int32_t)draw_line_dsc->p1_x;
|
||||
rect_area.x2 = (int32_t)draw_line_dsc->p2_x - 1;
|
||||
rect_area.y1 = (int32_t)LV_MAX(draw_line_dsc->p1_y, draw_line_dsc->p2_y) - 1;
|
||||
rect_area.x1 = (int32_t)draw_line_dsc->p1.x;
|
||||
rect_area.x2 = (int32_t)draw_line_dsc->p2.x - 1;
|
||||
rect_area.y1 = (int32_t)LV_MAX(draw_line_dsc->p1.y, draw_line_dsc->p2.y) - 1;
|
||||
rect_area.y2 = (int32_t)obj->coords.y2;
|
||||
lv_draw_rect(base_dsc->layer, &rect_dsc, &rect_area);
|
||||
}
|
||||
@@ -107,7 +107,7 @@ static void hook_division_lines(lv_event_t * e)
|
||||
lv_draw_line_dsc_t * line_dsc = draw_task->draw_dsc;
|
||||
|
||||
/*Vertical line*/
|
||||
if(line_dsc->p1_x == line_dsc->p2_x) {
|
||||
if(line_dsc->p1.x == line_dsc->p2.x) {
|
||||
line_dsc->color = lv_palette_lighten(LV_PALETTE_GREY, 1);
|
||||
if(base_dsc->id1 == 3) {
|
||||
line_dsc->width = 2;
|
||||
|
||||
Reference in New Issue
Block a user