Drawing dashed line in at any angle in the screen. How draw dashed line that can be placed at anywhere in the screen at any angle?

What do you want to achieve?

I want to draw a dashed line (6 dashes). That can be placed at anywhere in the screen at any angle. I drawn a dashed line at vertically and horizontally, but can’t draw at any other angle.

lv_obj_t *canvas = lv_canvas_create(lv_scr_act());

lv_color_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT)];

lv_canvas_set_buffer(canvas, cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, LV_IMG_CF_TRUE_COLOR);

lv_obj_set_pos(canvas, 50, 50); // initial position

lv_canvas_fill_bg(canvas, lv_color_white(), LV_OPA_COVER);

lv_point_t start = {20, 20};

lv_point_t end = {200, 100}; // Any angle you want

draw_dashed_line(canvas, start, end, 6, lv_color_hex(0xFF0000));?

Code to reproduce

/*You code here*/

Screenshot and/or video

Environment

  • MCU/MPU/Board: Zynq7020
  • LVGL version: 8.3.5