How to draw as rectangle

I use lvgl@8.3.6
I don’t get tried a lot of functions
in this function lv_layer_t is missing

void my_draw_function(lv_layer_t *layer) {
    // Erstelle einen Zeichnungsdeskriptor
    lv_draw_rect_dsc_t rect_dsc;
    lv_draw_rect_dsc_init(&rect_dsc);
    rect_dsc.bg_color = lv_color_red;
    rect_dsc.radius = 10;
    rect_dsc.border_width = 2;
    rect_dsc.border_color = lv_color_black;

    // Definiere die Koordinaten des Rechtecks
    lv_area_t rect_area;
    rect_area.x1 = 10;
    rect_area.y1 = 20;
    rect_area.x2 = 100;
    rect_area.y2 = 80;

    // Zeichne das Rechteck
    lv_draw_rect(layer, &rect_dsc, &rect_area);
}

Perhaps someone has an other function to draw a Rectangle

you can use lv_obj_create

I got it

            lv_obj_t * obj1;
          //  obj1 = lv_obj_create(lv_scr_act());
            obj1 = lv_obj_create(parent_obj);
            lv_obj_set_size(obj1, 100, 50);
            lv_obj_align(obj1, LV_ALIGN_CENTER, -60, -30);

            static lv_style_t style_shadow;
            lv_style_init(&style_shadow);
            lv_style_set_shadow_width(&style_shadow, 10);
            lv_style_set_shadow_spread(&style_shadow, 5);
            lv_style_set_shadow_color(&style_shadow, lv_palette_main(LV_PALETTE_BLUE));

            lv_obj_t * obj2;
            //obj2 = lv_obj_create(lv_scr_act());
            obj2 = lv_obj_create(parent_obj);
            lv_obj_add_style(obj2, &style_shadow, 0);
            lv_obj_align(obj2, LV_ALIGN_CENTER, 60, 30);

My fault I tried a Rect from Version 9 but it’s different in Ver 8
Thx Anyway

1 Like