1from imagetools import get_png_info, open_png
2
3def ofs_y_anim(img, v):
4    img.set_offset_y(v)
5    # print(img,v)
6
7# Register PNG image decoder
8decoder = lv.img.decoder_create()
9decoder.info_cb = get_png_info
10decoder.open_cb = open_png
11
12# Create an image from the png file
13try:
14    with open('../../assets/img_skew_strip.png','rb') as f:
15        png_data = f.read()
16except:
17    print("Could not find img_skew_strip.png")
18    sys.exit()
19
20img_skew_strip = lv.img_dsc_t({
21  'data_size': len(png_data),
22  'data': png_data
23})
24
25#
26# Image styling and offset
27#
28
29style = lv.style_t()
30style.init()
31style.set_bg_color(lv.palette_main(lv.PALETTE.YELLOW))
32style.set_bg_opa(lv.OPA.COVER)
33style.set_img_recolor_opa(lv.OPA.COVER)
34style.set_img_recolor(lv.color_black())
35
36img = lv.img(lv.scr_act())
37img.add_style(style, 0)
38img.set_src(img_skew_strip)
39img.set_size(150, 100)
40img.center()
41
42a = lv.anim_t()
43a.init()
44a.set_var(img)
45a.set_values(0, 100)
46a.set_time(3000)
47a.set_playback_time(500)
48a.set_repeat_count(lv.ANIM_REPEAT.INFINITE)
49a.set_custom_exec_cb(lambda a,val: ofs_y_anim(img,val))
50lv.anim_t.start(a)
51
52