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_img_4.py (1094B)

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