Ejemplo n.º 1
0
    def draw():
        l, r, w, h = 60, 60, 120, 120
        if __class__.state == 0:
            __class__.count += 1
            value = abs(int(get_count_curve(__class__.count, 3, 50) * 10))
            #print(value)

            pos = draw_dialog_alpha(ui.canvas,
                                    l - value // 2,
                                    r - value // 2,
                                    w + value,
                                    h + value,
                                    10,
                                    color=(255, 0, 0),
                                    alpha=230)
            if value >= 9:
                __class__.state = 1

        if __class__.state == 1:

            pos = draw_dialog_alpha(ui.canvas,
                                    l,
                                    r,
                                    w,
                                    h,
                                    10,
                                    color=(255, 0, 0),
                                    alpha=230)
            text = "It will show Message , return last pages after 3s"

            chunks, chunk_size = len(text), w // 12
            msg_lines = [
                text[i:i + chunk_size] for i in range(0, chunks, chunk_size)
            ]
            for i in range(len(msg_lines)):
                ui.canvas.draw_string(pos[0] + 16,
                                      pos[1] + 8 + 26 * i,
                                      msg_lines[i],
                                      scale=2,
                                      color=(0, 0, 0))

        if __class__.state == 2:
            __class__.count += 1
            value = abs(int(get_count_curve(__class__.count, 3, 50) * 10))

            pos = draw_dialog_alpha(ui.canvas,
                                    l - value // 2,
                                    r - value // 2,
                                    w + value,
                                    h + value,
                                    10,
                                    color=(255, 0, 0),
                                    alpha=230)
            if value == 0:
                container.latest()

        ui.display()
Ejemplo n.º 2
0
 def draw():
     height = 100 + int(get_time_curve(3, 250) * 60)
     pos = draw_dialog_alpha(ui.canvas,
                             20,
                             height,
                             200,
                             20,
                             10,
                             color=(255, 0, 0),
                             alpha=200)
     ui.canvas.draw_string(pos[0] + 10,
                           pos[1] + 10,
                           "Welcome to MaixUI",
                           scale=2,
                           color=(0, 0, 0))
     ui.display()
Ejemplo n.º 3
0
  def on_draw():

    CubeListBox.btn.expand_event()

    if CubeListBox.btn.next() == 2:
        CubeListBox.selected = CubeListBox.selected - 1
        if CubeListBox.selected < 0:
            CubeListBox.selected = 0
            list_rshift(CubeListBox.files)

    elif CubeListBox.btn.back() == 2:
        CubeListBox.selected = CubeListBox.selected + 1

        real_len = CubeListBox.limit
        if len(CubeListBox.files) < real_len:
            real_len = len(CubeListBox.files)

        if CubeListBox.selected > real_len - 1:
            CubeListBox.selected = real_len - 1
            list_lshift(CubeListBox.files)

    elif CubeListBox.btn.home() == 2:
        tmp = CubeListBox.files[CubeListBox.selected]
        # if tmp == '/':
        #     raise Exception('exit CubeListBox...')
        if tmp in ["../"] or tmp.find('.') == -1:
            CubeListBox.load_explorer(tmp)
            #list_lshift(CubeListBox.files)
        else:
            CubeListBox.info = tmp

    ui.canvas.draw_string(10, 5, str(CubeListBox.get_path(CubeListBox.paths)), scale=1)

    ui.canvas.draw_string(10, 225, str(CubeListBox.info), scale=1)

    CubeListBox.process = CubeListBox.process + 1 % 24
    tmp = 5 * math.cos(CubeListBox.process * (math.pi / 12))

    view_len = len(CubeListBox.files)
    if view_len > CubeListBox.limit:
        view_len = CubeListBox.limit

    for i in range(view_len):
        pos = draw_dialog_alpha(ui.canvas, 20, int(tmp) + 40 + i * 50, 200, 20, 10, color=(0,255,0) if CubeListBox.selected == i else (255, 0, 0), alpha=255 - i * 30)
        ui.canvas.draw_string(pos[0] + 10, pos[1] + 10, CubeListBox.files[i], scale=2, color=(0,0,0))
Ejemplo n.º 4
0
    def show_slide():
        l, r, w, h = 20, 210, 200, 40
        if __class__.state == 1:
            value = __class__.get_curve()
            pos = draw_dialog_alpha(ui.canvas,
                                    l,
                                    r + value // 2,
                                    w,
                                    h,
                                    10,
                                    color=(255, 0, 0),
                                    alpha=200 - value)
            pos = draw_dialog_alpha(ui.canvas,
                                    l + 50,
                                    r - 220 - value // 2,
                                    w - 100,
                                    h,
                                    10,
                                    color=(0, 0, 255),
                                    alpha=200 - value)
            if value <= 5:
                __class__.state = 2

        if __class__.state == 2:
            text = "It will show Message"
            pos = draw_dialog_alpha(ui.canvas,
                                    l,
                                    r,
                                    w,
                                    h,
                                    10,
                                    color=(255, 0, 0),
                                    alpha=220)
            ui.canvas.draw_string(pos[0] + 8,
                                  pos[1] + 10,
                                  text,
                                  scale=2,
                                  color=(0, 0, 0))
            text = "   Camera"
            pos = draw_dialog_alpha(ui.canvas,
                                    l + 50,
                                    r - 220,
                                    w - 100,
                                    h,
                                    10,
                                    color=(0, 0, 255),
                                    alpha=220)
            ui.canvas.draw_string(pos[0] + 8,
                                  pos[1] + 25,
                                  text,
                                  scale=2,
                                  color=(0, 0, 0))

        if __class__.state == 3:
            value = __class__.get_curve()
            pos = draw_dialog_alpha(ui.canvas,
                                    l,
                                    r + value // 2,
                                    w,
                                    h,
                                    10,
                                    color=(255, 0, 0),
                                    alpha=200 - value)
            pos = draw_dialog_alpha(ui.canvas,
                                    l + 50,
                                    r - 220 - value // 2,
                                    w - 100,
                                    h,
                                    10,
                                    color=(0, 0, 255),
                                    alpha=200 - value)
            if value >= __class__.limit - 5:
                __class__.state = __class__.count = 0
Ejemplo n.º 5
0
    return pow(res, level) if level != 1 else res

if __name__ == "__main__":
            
    from dialog import draw_dialog_alpha
    from ui_canvas import ui, print_mem_free
    import time
    last = time.ticks_ms()

    while True:
        ui.blank_draw()
        ui.grey_draw()
        ui.bg_in_draw()

        #print(time.ticks_ms() - last)
        #last = time.ticks_ms()

        height = 50 + (int(get_time_curve(3, 250) * 40))
        pos = draw_dialog_alpha(ui.canvas, 20, height, 200, 20, 10, color=(255, 0, 0), alpha=150)
        ui.canvas.draw_string(pos[0] + 10, pos[1] + 10, "time_curve(3, 250)", scale=2, color=(0,0,0))

        height = 100 + (int(get_time_curve(2, 500) * 40))
        pos = draw_dialog_alpha(ui.canvas, 20, height, 200, 20, 10, color=(0, 255, 0), alpha=150)
        ui.canvas.draw_string(pos[0] + 10, pos[1] + 10, "time_curve(2, 500)", scale=2, color=(0,0,0))

        height = 150 + (int(get_time_curve(1, 100) * 40))
        pos = draw_dialog_alpha(ui.canvas, 20, height, 200, 20, 10, color=(0, 0, 255), alpha=150)
        ui.canvas.draw_string(pos[0] + 10, pos[1] + 10, "time_curve(1, 100)", scale=2, color=(0,0,0))

        ui.display()