Draw a hollow rectangle (bounding box)


I want to draw a hollow rectangle (bounding box)
I have come up with some ideas, such as use lv_line and define the points, and use canvas.
According to my requirement, I would draw many bounding boxes with different sizes and positions.
To use lv_line, I need static points, but I don’t want to dynamically resize the array.

Therefore, I choose to use lv_canvas_draw_polygon to draw on the canvas.
I set the background to transparent and set the border width to draw a bounding box.
However, I don’t want the radius. (Based on the doc. “The border is drawn on top of the background. It has radius rounding”.)

Is there any way that I can remove(change) the border-radius?
Or if there is a more efficient way to draw a bounding box, please let me know.

Many thanks for your help.

Code to reproduce

    lv_draw_rect_dsc_t rect2; 
    rect2.bg_opa = LV_OPA_TRANSP;
    rect2.border_width = 30;
    rect2.border_color = LV_COLOR_RED;
    rect2.radius = 0;
    uint32_t pad = 20;
    lv_point_t po[] = {{x1-pad,y1-pad},{x1+width+pad,y1-pad},{x1+width+pad,y1+height+pad},{x1-pad,y1+height+pad},{x1-pad,y1-pad}};

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.

Could you just use an lv_obj with a transparent background color and non-transparent border?

Hi, I’ve tried.
However, if I set border, there is always radius.
Could you provide me how to disable border radius in lv_obj?
Many thanks.

Set the radius of the rectangles style.
See: https://docs.lvgl.io/latest/en/html/overview/style.html#mixed-properties