Rectangle (ls_rectangle_t)

A filled box with an optional border. The simplest widget, and the one panels and separator lines are built from.

ls_rectangle.hSource header · lvgl/lvgl_safe
 
ls_error_code_t ls_rectangle_create(ls_screen_t * screen, ls_rectangle_t * rectangle);
FieldTypeDescription
x, yuint32_tTop-left position
width, heightuint32_tSize in pixels
bg_colorls_color_tFill color
bg_opauint8_tFill opacity (0..255)
border_colorls_color_tBorder color
border_widthuint32_tBorder thickness in px; 0 (the default) means no border

Defaults after create: #cccccc fill, opaque; black border of width 0 (no border).

 
static ls_rectangle_t panel;

if(ls_rectangle_create(&screen, &panel) != LS_ERROR_CODE_OK) return 1;
panel.x = 20;
panel.y = 20;
panel.width = 280;
panel.height = 90;
panel.bg_color = LS_COLOR_HEX(0x1e242b);

/*A 1 px separator line, which is just a very thin rectangle.*/
static ls_rectangle_t line;

if(ls_rectangle_create(&screen, &line) != LS_ERROR_CODE_OK) return 1;
line.x = 20;
line.y = 120;
line.width = 280;
line.height = 1;
line.bg_color = LS_COLOR_HEX(0x2b333c);

NOTE: border rendering is not yet implemented.

Last updated on