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_canvas_1.py (1439B)

      1 _CANVAS_WIDTH = 200
      2 _CANVAS_HEIGHT = 150
      3 LV_IMG_ZOOM_NONE = 256
      4 
      5 rect_dsc = lv.draw_rect_dsc_t()
      6 rect_dsc.init()
      7 rect_dsc.radius = 10
      8 rect_dsc.bg_opa = lv.OPA.COVER
      9 rect_dsc.bg_grad.dir = lv.GRAD_DIR.HOR
     10 rect_dsc.bg_grad.stops[0].color = lv.palette_main(lv.PALETTE.RED)
     11 rect_dsc.bg_grad.stops[1].color = lv.palette_main(lv.PALETTE.BLUE)
     12 rect_dsc.border_width = 2
     13 rect_dsc.border_opa = lv.OPA._90
     14 rect_dsc.border_color = lv.color_white()
     15 rect_dsc.shadow_width = 5
     16 rect_dsc.shadow_ofs_x = 5
     17 rect_dsc.shadow_ofs_y = 5
     18 
     19 label_dsc = lv.draw_label_dsc_t()
     20 label_dsc.init()
     21 label_dsc.color = lv.palette_main(lv.PALETTE.YELLOW)
     22 
     23 cbuf = bytearray(_CANVAS_WIDTH * _CANVAS_HEIGHT * 4)
     24 
     25 canvas = lv.canvas(lv.scr_act())
     26 canvas.set_buffer(cbuf, _CANVAS_WIDTH, _CANVAS_HEIGHT, lv.img.CF.TRUE_COLOR)
     27 canvas.center()
     28 canvas.fill_bg(lv.palette_lighten(lv.PALETTE.GREY, 3), lv.OPA.COVER)
     29 
     30 canvas.draw_rect(70, 60, 100, 70, rect_dsc)
     31 canvas.draw_text(40, 20, 100, label_dsc, "Some text on text canvas")
     32 
     33 # Test the rotation. It requires another buffer where the original image is stored.
     34 # So copy the current image to buffer and rotate it to the canvas
     35 
     36 img = lv.img_dsc_t()
     37 img.data = cbuf[:]
     38 img.header.cf = lv.img.CF.TRUE_COLOR
     39 img.header.w = _CANVAS_WIDTH
     40 img.header.h = _CANVAS_HEIGHT
     41 
     42 canvas.fill_bg(lv.palette_lighten(lv.PALETTE.GREY, 3), lv.OPA.COVER)
     43 canvas.transform(img, 30, LV_IMG_ZOOM_NONE, 0, 0, _CANVAS_WIDTH // 2, _CANVAS_HEIGHT // 2, True)