acid-drop

- Hacking the planet from a LilyGo T-Deck using custom firmware
git clone git://git.acid.vegas/acid-drop.git
Log | Files | Refs | Archive | README | LICENSE

lv_example_label_2.c (1193B)

      1 #include "../../lv_examples.h"
      2 #if LV_USE_LABEL && LV_BUILD_EXAMPLES
      3 
      4 /**
      5  * Create a fake text shadow
      6  */
      7 void lv_example_label_2(void)
      8 {
      9     /*Create a style for the shadow*/
     10     static lv_style_t style_shadow;
     11     lv_style_init(&style_shadow);
     12     lv_style_set_text_opa(&style_shadow, LV_OPA_30);
     13     lv_style_set_text_color(&style_shadow, lv_color_black());
     14 
     15     /*Create a label for the shadow first (it's in the background)*/
     16     lv_obj_t * shadow_label = lv_label_create(lv_scr_act());
     17     lv_obj_add_style(shadow_label, &style_shadow, 0);
     18 
     19     /*Create the main label*/
     20     lv_obj_t * main_label = lv_label_create(lv_scr_act());
     21     lv_label_set_text(main_label, "A simple method to create\n"
     22                       "shadows on a text.\n"
     23                       "It even works with\n\n"
     24                       "newlines     and spaces.");
     25 
     26     /*Set the same text for the shadow label*/
     27     lv_label_set_text(shadow_label, lv_label_get_text(main_label));
     28 
     29     /*Position the main label*/
     30     lv_obj_align(main_label, LV_ALIGN_CENTER, 0, 0);
     31 
     32     /*Shift the second label down and to the right by 2 pixel*/
     33     lv_obj_align_to(shadow_label, main_label, LV_ALIGN_TOP_LEFT, 2, 2);
     34 }
     35 
     36 #endif