How to fill a rectangle, circle and triangle

Description

How to fill a rectangle, circle and triangle

What MCU/Processor/Board and compiler are you using?

STM32F407IGT6

What LVGL version are you using?

7.3.0

What do you want to achieve?

How to fill a rectangle, circle and triangle

I copy the source code to write a control, want to draw a filled graphics, but i do not know how to draw a filled graphics

What have you tried so far?

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/

Screenshot and/or video

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

Have you already drawn “empty” shapes? If so, please send a code snippet about it.

    lv_area_t area;
    lv_obj_get_coords(cube, &area);
    lv_coord_t x_ofs = area.x1;
    lv_coord_t y_ofs = area.y1;
    lv_point_t p1;
    lv_point_t p2;

    p1.x = x_ofs;p1.y = y_ofs;
    p2.x = x_ofs + lv_obj_get_width(cube);p2.y = y_ofs;
    lv_draw_line(&p1, &p2, clip_area, &line_dsc);line_dsc.round_start = 0;
    p1.x = x_ofs;p1.y = y_ofs;
    p2.x = x_ofs;p2.y = y_ofs + lv_obj_get_height(cube);
    lv_draw_line(&p1, &p2, clip_area, &line_dsc);line_dsc.round_start = 0;
    p1.x = x_ofs + lv_obj_get_width(cube);p1.y = y_ofs;
    p2.x = x_ofs + lv_obj_get_width(cube);p2.y = y_ofs + lv_obj_get_height(cube);
    lv_draw_line(&p1, &p2, clip_area, &line_dsc);line_dsc.round_start = 0;
    p1.x = x_ofs;p1.y = y_ofs + lv_obj_get_height(cube);
    p2.x = x_ofs + lv_obj_get_width(cube);p2.y = y_ofs + lv_obj_get_height(cube);
    lv_draw_line(&p1, &p2, clip_area, &line_dsc);line_dsc.round_start = 0;

I have learned a way to split a quadrilateral into two horizontal sides, and then fill the two triangles line by line. The advantage is that you can fill any quadrilateral or even polygon.

Draw a hollow shape, but there is no way to fill it

You can use lv_draw_polygon.