1 /**
2  * @file lv_draw_rect.c
3  *
4  */
5 
6 /*********************
7  *      INCLUDES
8  *********************/
9 #include "lv_draw.h"
10 #include "lv_draw_rect.h"
11 #include "../misc/lv_assert.h"
12 
13 /*********************
14  *      DEFINES
15  *********************/
16 
17 /**********************
18  *      TYPEDEFS
19  **********************/
20 
21 /**********************
22  *  STATIC PROTOTYPES
23  **********************/
24 
25 /**********************
26  *  STATIC VARIABLES
27  **********************/
28 
29 /**********************
30  *      MACROS
31  **********************/
32 
33 /**********************
34  *   GLOBAL FUNCTIONS
35  **********************/
36 
lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc)37 LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc)
38 {
39     lv_memset_00(dsc, sizeof(lv_draw_rect_dsc_t));
40     dsc->bg_color = lv_color_white();
41     dsc->bg_grad.stops[0].color = lv_color_white();
42     dsc->bg_grad.stops[1].color = lv_color_black();
43     dsc->bg_grad.stops[1].frac = 0xFF;
44     dsc->bg_grad.stops_count = 2;
45     dsc->border_color = lv_color_black();
46     dsc->shadow_color = lv_color_black();
47     dsc->bg_img_symbol_font = LV_FONT_DEFAULT;
48     dsc->bg_opa = LV_OPA_COVER;
49     dsc->bg_img_opa = LV_OPA_COVER;
50     dsc->outline_opa = LV_OPA_COVER;
51     dsc->border_opa = LV_OPA_COVER;
52     dsc->shadow_opa = LV_OPA_COVER;
53     dsc->border_side = LV_BORDER_SIDE_FULL;
54 }
55 
56 /**
57  * Draw a rectangle
58  * @param coords the coordinates of the rectangle
59  * @param mask the rectangle will be drawn only in this mask
60  * @param dsc pointer to an initialized `lv_draw_rect_dsc_t` variable
61  */
lv_draw_rect(lv_draw_ctx_t * draw_ctx,const lv_draw_rect_dsc_t * dsc,const lv_area_t * coords)62 void lv_draw_rect(lv_draw_ctx_t * draw_ctx, const lv_draw_rect_dsc_t * dsc, const lv_area_t * coords)
63 {
64     if(lv_area_get_height(coords) < 1 || lv_area_get_width(coords) < 1) return;
65 
66     draw_ctx->draw_rect(draw_ctx, dsc, coords);
67 
68     LV_ASSERT_MEM_INTEGRITY();
69 }
70 
71 /**********************
72  *   STATIC FUNCTIONS
73  **********************/
74