mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
49 lines
1.5 KiB
C
49 lines
1.5 KiB
C
#include "../lv_examples.h"
|
|
#if LV_BUILD_EXAMPLES && LV_USE_BUTTON && LV_USE_LABEL
|
|
|
|
/**
|
|
* Opacity and Transformations
|
|
*/
|
|
void lv_example_style_15(void)
|
|
{
|
|
lv_obj_t * btn;
|
|
lv_obj_t * label;
|
|
|
|
/*Normal button*/
|
|
btn = lv_button_create(lv_screen_active());
|
|
lv_obj_set_size(btn, 100, 40);
|
|
lv_obj_align(btn, LV_ALIGN_CENTER, 0, -70);
|
|
|
|
label = lv_label_create(btn);
|
|
lv_label_set_text(label, "Normal");
|
|
lv_obj_center(label);
|
|
|
|
/*Set opacity
|
|
*The button and the label is rendered to a layer first and that layer is blended*/
|
|
btn = lv_button_create(lv_screen_active());
|
|
lv_obj_set_size(btn, 100, 40);
|
|
lv_obj_set_style_opa(btn, LV_OPA_50, 0);
|
|
lv_obj_align(btn, LV_ALIGN_CENTER, 0, 0);
|
|
|
|
label = lv_label_create(btn);
|
|
lv_label_set_text(label, "Opa:50%");
|
|
lv_obj_center(label);
|
|
|
|
/*Set transformations
|
|
*The button and the label is rendered to a layer first and that layer is transformed*/
|
|
btn = lv_button_create(lv_screen_active());
|
|
lv_obj_set_size(btn, 100, 40);
|
|
lv_obj_set_style_transform_rotation(btn, 150, 0); /*15 deg*/
|
|
lv_obj_set_style_transform_scale(btn, 256 + 64, 0); /*1.25x*/
|
|
lv_obj_set_style_transform_pivot_x(btn, 50, 0);
|
|
lv_obj_set_style_transform_pivot_y(btn, 20, 0);
|
|
lv_obj_set_style_opa(btn, LV_OPA_50, 0);
|
|
lv_obj_align(btn, LV_ALIGN_CENTER, 0, 70);
|
|
|
|
label = lv_label_create(btn);
|
|
lv_label_set_text(label, "Transf.");
|
|
lv_obj_center(label);
|
|
}
|
|
|
|
#endif
|