当前位置:网站首页>LVGL 8.2 re-coloring
LVGL 8.2 re-coloring
2022-06-30 10:54:00 【Fairy sword love】
Defining variables
static lv_obj_t* red_slider, * green_slider, * blue_slider, * intense_slider;
static lv_obj_t* img1;
Event handling callback function
static void slider_event_cb(lv_event_t* e)
{
LV_UNUSED(e);
/*Recolor the image based on the sliders' values*/
lv_color_t color = lv_color_make(lv_slider_get_value(red_slider), lv_slider_get_value(green_slider),
lv_slider_get_value(blue_slider)); // Get three slider The value of the composition RGB Color
lv_opa_t intense = lv_slider_get_value(intense_slider); // obtain slider Value of constitutes transparency
lv_obj_set_style_img_recolor_opa(img1, intense, 0); // Recolor colors
lv_obj_set_style_img_recolor(img1, color, 0); // Recolor transparency
}
establish slider
static lv_obj_t* create_slider(lv_color_t color)
{
lv_obj_t* slider = lv_slider_create(lv_scr_act()); // establish slider object
lv_slider_set_range(slider, 0, 255); // set range 0~255
lv_obj_set_size(slider, 10, 200); // Set up slider size
lv_obj_set_style_bg_color(slider, color, LV_PART_KNOB); // Set up knob The background color
lv_obj_set_style_bg_color(slider, lv_color_darken(color, LV_OPA_40), LV_PART_INDICATOR); // Set up indicator Back sway color
lv_obj_add_event_cb(slider, slider_event_cb, LV_EVENT_VALUE_CHANGED, NULL); // Add registration LV_EVENT_VALUE_CHANGED event
return slider; // return slider object
}
/** * Demonstrate runtime image re-coloring */
static void lv_example_img_2(void)
{
/*Create 4 sliders to adjust RGB color and re-color intensity*/
red_slider = create_slider(lv_palette_main(LV_PALETTE_RED)); // Create red slider
green_slider = create_slider(lv_palette_main(LV_PALETTE_GREEN));// Create green slider
blue_slider = create_slider(lv_palette_main(LV_PALETTE_BLUE));// Create blue slider
intense_slider = create_slider(lv_palette_main(LV_PALETTE_GREY));// Create gray slider
lv_slider_set_value(red_slider, LV_OPA_20, LV_ANIM_OFF); // Set the initial value and close slider Control animation effect
lv_slider_set_value(green_slider, LV_OPA_90, LV_ANIM_OFF);// Set the initial value and close slider Control animation effect
lv_slider_set_value(blue_slider, LV_OPA_60, LV_ANIM_OFF);// Set the initial value and close slider Control animation effect
lv_slider_set_value(intense_slider, LV_OPA_50, LV_ANIM_OFF);// Set the initial value and close slider Control animation effect
lv_obj_align(red_slider, LV_ALIGN_LEFT_MID, 25, 0);//LV_ALIGN_LEFT_MID Alignment
lv_obj_align_to(green_slider, red_slider, LV_ALIGN_OUT_RIGHT_MID, 25, 0);//green_slider Align to red_slider Outer frame right middle 25,0 It's about
lv_obj_align_to(blue_slider, green_slider, LV_ALIGN_OUT_RIGHT_MID, 25, 0);//blue_slider Align to green_slider Outer frame right middle 25,0 It's about
lv_obj_align_to(intense_slider, blue_slider, LV_ALIGN_OUT_RIGHT_MID, 25, 0);//intense_slider Align to blue_slider Outer frame right middle 25,0 It's about
/*Now create the actual image*/
LV_IMG_DECLARE(img_cogwheel_argb) // Declare image resources
img1 = lv_img_create(lv_scr_act()); // establish image object
lv_img_set_src(img1, &img_cogwheel_argb); // Set pictures
lv_obj_align_to(img1, intense_slider, LV_ALIGN_OUT_RIGHT_MID, 25, 0);//img1 Align to blue_slider Outer frame right middle 25,0 It's about
lv_event_send(intensintense_slidere_slider, LV_EVENT_VALUE_CHANGED, NULL); // towards intense_slider Control sending LV_EVENT_VALUE_CHANGED event
}
Running effect

边栏推荐
- LVGL8.2 Simple Checkboxes
- The two e-commerce bigwigs' lacy news screens represent the return of e-commerce to normal, which will be beneficial to the real economy
- LVGL 8.2 Checkboxes as radio buttons
- scratch绘制正方形 电子学会图形化编程scratch等级考试二级真题和答案解析2022年6月
- Auto SEG loss: automatic loss function design
- MySQL导出sql脚本文件
- Gd32 RT thread ota/bootloader driver function
- [deep learning] common methods for deep learning to detect small targets
- Mysql database foundation: views and variables
- 电化学氧气传感器寿命、工作原理及应用介绍
猜你喜欢
[email protected] voice module +stm32+nfc"/>Skill combing [email protected] voice module +stm32+nfc

Review of mathematical knowledge: curve integral of the second type

【STL源码剖析】容器(待补充)

CP2112使用USB转IIC通信教学示例

Robotframework learning notes: environment installation and robotframework browser plug-in installation

电商两位大佬花边新闻刷屏,代表电商回归正常,将有利于实体经济

List introduction

go-zero微服务实战系列(八、如何处理每秒上万次的下单请求)

scratch绘制正方形 电子学会图形化编程scratch等级考试二级真题和答案解析2022年6月

文件共享服务器
随机推荐
Cp2112 teaching example of using USB to IIC communication
ArrayList and sequence table
Gd32 RT thread RTC driver function
[机缘参悟-34]:光锥之内皆命运
59 websites programmers need to know
20万奖金池!【阿里安全 × ICDM 2022】大规模电商图上的风险商品检测赛火热报名中!...
DQN笔记
June training (day 30) - topology sorting
数学知识复习:第二型曲线积分
The programmer was beaten.
Typescript – classes in Es5, inheritance, static methods
Didi open source agile test case management platform!
断路器HystrixCircuitBreaker
iptables目标TPROXY
Robotframework learning notes: environment installation and robotframework browser plug-in installation
Skill combing [email protected] somatosensory manipulator
煥發青春的戴爾和蘋果夾擊,兩大老牌PC企業極速衰敗
前嗅ForeSpider教程:抽取数据
Classic interview question: responsible modules, how do you design test cases for these function points? [Hangzhou multi surveyors] [Hangzhou multi surveyors \wang Sir]
LVGL 8.2 Checkboxes as radio buttons