Example #1
0
def testfastlines(canvas, color1, color2):
    # there are no hline and vline calls in the lvgl display driver
    # replace them by normal lines

    p1 = lv.point_t()
    p2 = lv.point_t()
    point_array = [p1, p2]

    # style for horizontal lines
    hline_dsc = lv.draw_line_dsc_t()
    hline_dsc.init()
    hline_dsc.color = color1
    hline_dsc.opa = lv.OPA.COVER

    # style for vertical lines
    vline_dsc = lv.draw_line_dsc_t()
    vline_dsc.init()
    vline_dsc.color = color2
    vline_dsc.opa = lv.OPA.COVER

    print("Test horizontal and vertical fast lines")

    p1.x = 0
    p2.x = CANVAS_WIDTH - 1
    for y in range(0, CANVAS_HEIGHT - 1, 5):
        p1.y = y
        p2.y = y
        canvas.draw_line(point_array, 2, hline_dsc)
    p1.y = 0
    p2.y = CANVAS_HEIGHT - 1
    for x in range(0, CANVAS_WIDTH - 1, 5):
        p1.x = x
        p2.x = x
        canvas.draw_line(point_array, 2, vline_dsc)
Example #2
0
def testtriangles(canvas):
    print("Test triangles")
    offset = (CANVAS_WIDTH - CANVAS_HEIGHT) // 2
    p1 = lv.point_t()
    p2 = lv.point_t()
    point_array = [p1, p2]
    line_dsc = lv.draw_line_dsc_t()
    line_dsc.init()
    w = CANVAS_HEIGHT // 2
    x = CANVAS_HEIGHT - 1
    y = 0
    z = CANVAS_HEIGHT - 1
    for i in range(0, 15):
        line_dsc.color = colors[i]
        p1.x = w + offset
        p1.y = y
        p2.x = y + offset
        p2.y = x
        canvas.draw_line(point_array, 2, line_dsc)
        p1.x = y + offset
        p1.y = x
        p2.x = z + offset
        canvas.draw_line(point_array, 2, line_dsc)
        p1.x = z + offset
        p2.x = w + offset
        p2.y = y
        canvas.draw_line(point_array, 2, line_dsc)
        x -= 8
        y += 8
        z -= 8
Example #3
0
    def __init__(self):

        self.value = 0
        canvas_style = lv.style_t()
        canvas_style.init()
        canvas_style.set_bg_color(lv.STATE.DEFAULT, lv_colors.WHITE)

        cbuf = bytearray(SCREEN_WIDTH * 30 * 4)
        canvas = lv.canvas(lv.scr_act(), None)
        canvas.set_buffer(cbuf, SCREEN_WIDTH, 30, lv.img.CF.TRUE_COLOR)
        # canvas.add_style(lv.canvas.PART.MAIN,canvas_style)
        canvas.align(None, lv.ALIGN.IN_TOP_LEFT, 0, 0)

        p1 = lv.point_t()
        p2 = lv.point_t()
        point_array = [p1, p2]
        p1.x = 0
        p1.y = 0
        p2.x = 15
        p2.y = p1.y

        # style for horizontal lines
        line_dsc = lv.draw_line_dsc_t()
        line_dsc.init()
        line_dsc.color = lv_colors.BLUE
        line_dsc.opa = lv.OPA.COVER
        line_dsc.width = 5

        # draw the horizontal lines

        canvas.draw_line(point_array, 2, line_dsc)
        p1.x = 130
        p2.x = SCREEN_WIDTH
        canvas.draw_line(point_array, 2, line_dsc)

        # draw the vertical lines

        p1.x = 0
        p2.x = p1.x
        p2.y = 30
        canvas.draw_line(point_array, 2, line_dsc)

        p1.x = SCREEN_WIDTH - 3
        p2.x = p1.x
        canvas.draw_line(point_array, 2, line_dsc)

        text_style = lv.style_t()
        text_style.init()
        text_style.set_text_font(lv.STATE.DEFAULT, lv.font_montserrat_18)
        text_style.set_bg_color(lv.STATE.DEFAULT, lv_colors.BLACK)
        text_style.set_bg_opa(lv.STATE.DEFAULT, lv.OPA.COVER)

        self.label = lv.label(canvas, None)
        self.label.add_style(lv.label.PART.MAIN, text_style)
        self.label.set_recolor(True)

        self.reset()
        self.label.align(None, lv.ALIGN.OUT_TOP_MID, -60, 25)
Example #4
0
def testdrawcircles(canvas, radius, color):
    print("Test circles")
    circle_dsc = lv.draw_line_dsc_t()
    circle_dsc.init()
    circle_dsc.color = color

    for x in range(0, CANVAS_WIDTH + radius, radius * 2):
        for y in range(0, CANVAS_HEIGHT + radius, radius * 2):
            canvas.draw_arc(x, y, radius, 0, 360, circle_dsc)
Example #5
0
def draw_lines(canvas, points, color):
    line_dsc = lv.draw_line_dsc_t()
    line_dsc.init()
    line_dsc.color = color
    line_dsc.opa = lv.OPA.COVER

    print(len(points))
    for i in range(len(points) - 1):
        point_array = [points[i], points[i + 1]]
        canvas.draw_line(point_array, 2, line_dsc)
Example #6
0
    def main_page(self, tile_num):
        self.aclock_tile = self.mainbar.get_tile_obj(tile_num)
        self.aclock_style = lv.style_t()
        self.aclock_style.copy(self.mainbar.get_style())

        self.CANVAS_HEIGHT = lv.scr_act().get_disp().driver.ver_res
        self.CANVAS_WIDTH = self.CANVAS_HEIGHT
        cbuf = bytearray(self.CANVAS_HEIGHT * self.CANVAS_HEIGHT * 4)

        self.canvas = lv.canvas(self.aclock_tile, None)
        self.canvas.set_buffer(cbuf, self.CANVAS_HEIGHT, self.CANVAS_HEIGHT,
                               lv.img.CF.TRUE_COLOR)
        self.canvas.align(self.aclock_tile, lv.ALIGN.CENTER, 0, 0)

        circle_dsc = lv.draw_line_dsc_t()
        circle_dsc.init()
        circle_dsc.color = lv_colors.GREEN
        self.radius = 90
        xo = self.CANVAS_WIDTH // 2
        yo = self.CANVAS_HEIGHT // 2 - 20
        self.canvas.draw_arc(xo, yo, self.radius, 0, 360, circle_dsc)
        vor = xo + 1j * yo
        vtstart = 0.9 * self.radius + 0j  # start of tick
        vtick = 0.1 * self.radius + 0j  # tick
        vrot = cmath.exp(2j * cmath.pi / 12)  # unit rotation
        for _ in range(12):
            polar(self.canvas, vor + conj(vtstart), vtick, 1, lv_colors.GREEN)
            vtick *= vrot
            vtstart *= vrot

        vtick = 0.05 * self.radius + 0j  # tick
        vrot = cmath.exp(2j * cmath.pi / 60)  # unit rotation
        for _ in range(60):
            polar(self.canvas, vor + conj(vtstart), vtick, 1, lv_colors.GREEN)
            vtick *= vrot
            vtstart *= vrot
            self.hrs_radius = self.radius - 32
            self.min_radius = self.radius - 12
            self.sec_radius = self.radius - 12

        self.task = lv.task_create_basic()
        self.task.set_cb(lambda task: self.updateClock(self.task))
        self.task.set_period(100)
        self.task.set_prio(lv.TASK_PRIO.LOWEST)

        exit_btn = lv.imgbtn(self.aclock_tile, None)
        exit_btn.set_src(lv.btn.STATE.RELEASED,
                         self.mainbar.get_exit_btn_dsc())
        exit_btn.add_style(lv.imgbtn.PART.MAIN, self.aclock_style)
        exit_btn.align(self.aclock_tile, lv.ALIGN.IN_BOTTOM_LEFT, 10, -10)
        self.log.debug("setting up exit callback")
        exit_btn.set_event_cb(self.exit_aclock_app_event_cb)

        self.aclock_style.set_text_opa(lv.obj.PART.MAIN, lv.OPA.COVER)
Example #7
0
def draw_filledCircle(canvas, x0, y0, r, color):
    """Draw a filled circle.
    
    Args:
       x0 (int): X coordinate of center point.
       y0 (int): Y coordinate of center point.
       r (int): Radius.
       color (int): RGB565 color value.
    """
    p1 = lv.point_t()
    p2 = lv.point_t()
    point_array = [p1, p2]

    line_dsc = lv.draw_line_dsc_t()
    line_dsc.init()
    line_dsc.color = color
    line_dsc.opa = lv.OPA.COVER

    f = 1 - r
    dx = 1
    dy = -r - r
    x = 0
    y = r
    p1.x = x0
    p1.y = y0 - r
    p2.x = p1.x
    p2.y = p1.y + 2 * r + 1
    canvas.draw_line(point_array, 2, line_dsc)
    while x < y:
        if f >= 0:
            y -= 1
            dy += 2
            f += dy
        x += 1
        dx += 2
        f += dx
        p1.x = x0 + x
        p1.y = y0 - y
        p2.x = p1.x
        p2.y = p1.y + 2 * y + 1
        canvas.draw_line(point_array, 2, line_dsc)
        p1.x = x0 - x
        p2.x = p1.x
        canvas.draw_line(point_array, 2, line_dsc)
        p1.x = x0 - y
        p1.y = y0 - x
        p2.x = p1.x
        p2.y = p1.y + 2 * x + 1
        canvas.draw_line(point_array, 2, line_dsc)
        p1.x = x0 + y
        p2.x = p1.x
        canvas.draw_line(point_array, 2, line_dsc)
Example #8
0
def polar(canvas, origin, line, width, color):
    line_dsc = lv.draw_line_dsc_t()
    line_dsc.init()
    line_dsc.color = color
    line_dsc.width = width
    p1 = lv.point_t()
    p2 = lv.point_t()
    point_array = [p1, p2]

    xs, ys = origin.real, origin.imag
    p1.x = round(xs)
    p1.y = round(ys)
    p2.x = round(xs + line.real)
    p2.y = round(ys - line.imag)
    # print("x0: %d, y0: %d, x1: %d, y1: %d"%(round(xs), round(ys), round(xs + line.real), round(ys - line.imag)))
    canvas.draw_line(point_array, 2, line_dsc)
Example #9
0
    def __init__(self,parent):
        
        self.CANVAS_HEIGHT = lv.scr_act().get_disp().driver.ver_res
        self.CANVAS_WIDTH = self.CANVAS_HEIGHT
        cbuf=bytearray(self.CANVAS_HEIGHT * self.CANVAS_HEIGHT * 4)

        self.canvas = lv.canvas(parent,None)
        self.canvas.set_buffer(cbuf,self.CANVAS_HEIGHT,self.CANVAS_HEIGHT,lv.img.CF.TRUE_COLOR)
        self.canvas.align(None,lv.ALIGN.CENTER,0,0)
        
        circle_dsc = lv.draw_line_dsc_t()
        circle_dsc.init()
        circle_dsc.color = lv_colors.GREEN
        self.radius = 90
        xo=self.CANVAS_WIDTH//2
        yo=self.CANVAS_HEIGHT//2-20
        self.canvas.draw_arc(xo,yo,self.radius,0,360,circle_dsc)
        vor = xo + 1j * yo
        vtstart = 0.9 * self.radius + 0j  # start of tick
        vtick = 0.1 * self.radius + 0j  # tick
        vrot = cmath.exp(2j * cmath.pi/12)  # unit rotation
        for _ in range(12):
            polar(self.canvas, vor + conj(vtstart), vtick, 1, lv_colors.GREEN)
            vtick *= vrot
            vtstart *= vrot
            
        vtick = 0.05 * self.radius + 0j  # tick
        vrot = cmath.exp(2j * cmath.pi/60)  # unit rotation
        for _ in range(60):
            polar(self.canvas, vor + conj(vtstart), vtick, 1, lv_colors.GREEN)
            vtick *= vrot
            vtstart *= vrot
            self.hrs_radius = self.radius-32
            self.min_radius = self.radius -12
            self.sec_radius = self.radius -12

        self.task = lv.task_create_basic()
        self.task.set_cb(lambda task: self.updateClock(self.task))
        self.task.set_period(100)
        self.task.set_prio(lv.TASK_PRIO.LOWEST)
def test():
    """Test code."""
    cbuf = bytearray(CANVAS_WIDTH * CANVAS_HEIGHT * 4)
    # create a canvas
    canvas = lv.canvas(lv.scr_act(), None)
    canvas.set_buffer(cbuf, CANVAS_WIDTH, CANVAS_HEIGHT, lv.img.CF.TRUE_COLOR)
    canvas.align(None, lv.ALIGN.CENTER, 0, 0)

    p1 = lv.point_t()
    p2 = lv.point_t()
    point_array = [p1, p2]

    p2.x = CENTER_X
    p2.y = CENTER_Y
    line_dsc = lv.draw_line_dsc_t()
    line_dsc.init()
    line_dsc.opa = lv.OPA.COVER
    x, y = 0, 0
    angle = 0.0
    #  Loop all angles from 0 to 2 * PI radians
    while angle < PI2:
        # Calculate x, y from a vector with known length and angle
        x = int(CENTER_Y * sin(angle) + HALF_WIDTH)
        y = int(CENTER_Y * cos(angle) + HALF_HEIGHT)
        color = LV_COLOR_MAKE(*hsv_to_rgb(angle / PI2, 1, 1))
        line_dsc.color = color
        p1.x = x
        p1.y = y
        canvas.draw_line(point_array, 2, line_dsc)
        angle += ANGLE_STEP_SIZE

    sleep(5)
    clear(canvas)
    line_dsc.width = 3
    for r in range(CENTER_Y, 0, -1):
        line_dsc.color = LV_COLOR_MAKE(*hsv_to_rgb(r / HALF_HEIGHT, 1, 1))

        canvas.draw_arc(CENTER_X, CENTER_Y, r, 0, 360, line_dsc)

    sleep(5)
Example #11
0
    def __init__(self, page):
        self.cbuf = bytearray(CANVAS_WIDTH * CANVAS_HEIGHT * 4)

        # create a canvas
        self.canvas = lv.canvas(page, None)
        self.canvas.set_buffer(self.cbuf,CANVAS_WIDTH,CANVAS_HEIGHT,lv.img.CF.TRUE_COLOR)
        self.canvas.align(page,lv.ALIGN.CENTER,0,0)
        self.clear();

        # prepare line
        self.line_dsc = lv.draw_line_dsc_t()
        self.line_dsc.init()
        self.line_dsc.color = lv.color_hex(0xff0000);
        self.line_dsc.opa = lv.OPA.COVER

        self.color_state = (0,0)
        self.x = 0
        self.y = CANVAS_HEIGHT-1
        self.state = 0
        
        # the line drawing is done by a task so it doesn't interfere
        # with LVGL itself
        self.task = lv.task_create(self.line_task, 10, lv.TASK_PRIO.MID, None);
Example #12
0
    def __init__(self,
                 x=None,
                 y=None,
                 min_value=0,
                 max_value=100,
                 value=50,
                 divisions=5,
                 legend=None,
                 label_text=None,
                 value_text_format=None,
                 bar_color=lv_colors.BLUE,
                 legend_color=lv_colors.YELLOW,
                 value_color=lv_colors.WHITE,
                 bg_color=lv_colors.BLACK):

        self.x = x
        self.y = y
        self.min_value = min_value
        self.max_value = max_value
        self.value = value
        self.width = 40
        self.height = 104
        self.label_text = label_text
        self.value_text_format = value_text_format
        self.bg_color = bg_color
        self.bar_color = bar_color
        self.value_color = value_color
        self.legend_color = legend_color
        self.base = 102
        if legend:
            self.divisions = len(legend) - 1
        else:
            self.divisions = divisions

        scr_style = lv.style_t()
        scr_style.set_bg_color(lv.STATE.DEFAULT, self.bg_color)
        lv.scr_act().add_style(lv.obj.PART.MAIN, scr_style)

        # create a container

        self.container = lv.cont(lv.scr_act(), None)
        self.container.set_fit(lv.FIT.TIGHT)
        self.container.align(None, lv.ALIGN.CENTER, 0, 0)
        if self.x:
            self.container.set_x(self.x)
        if self.y:
            self.container.set_y(self.y)
        self.container.add_style(lv.obj.PART.MAIN, scr_style)

        cbuf = bytearray(self.width * self.height * 4)

        # create a canvas
        self.canvas = lv.canvas(self.container, None)
        self.canvas.set_buffer(cbuf, self.width, self.height,
                               lv.img.CF.TRUE_COLOR)
        self.canvas.align(self.container, lv.ALIGN.CENTER, 0, -50)

        text_style = lv.style_t()
        text_style.init()
        text_style.set_text_color(lv.STATE.DEFAULT, self.legend_color)

        if self.value_text_format:
            value_text_style = lv.style_t()
            value_text_style.init()
            value_text_style.set_text_color(lv.STATE.DEFAULT, self.value_color)
            self.value_label = lv.label(self.container)
            self.value_label.add_style(lv.label.PART.MAIN, value_text_style)
            value_text = self.value_text_format.format(self.value)
            self.value_label.set_text(value_text)

        if self.label_text:
            self.label = lv.label(self.container)
            self.label.set_text(label_text)
            self.label.align(self.canvas, lv.ALIGN.OUT_BOTTOM_MID, 0, 10)

            self.label.add_style(lv.label.PART.MAIN, text_style)
            if self.value_text_format:
                self.value_label.align(self.label, lv.ALIGN.OUT_BOTTOM_MID, 0,
                                       0)
        else:
            self.value_label.align(self.canvas, lv.ALIGN.OUT_BOTTOM_MID, 0, 10)

        #bar = lv_bar(container)

        p1 = lv.point_t()
        p2 = lv.point_t()
        point_array = [p1, p2]

        # style for horizontal lines
        self.hline_dsc = lv.draw_line_dsc_t()
        self.hline_dsc.init()
        self.hline_dsc.color = self.legend_color
        self.hline_dsc.opa = lv.OPA.COVER

        rect_dsc = lv.draw_rect_dsc_t()
        rect_dsc.init()
        rect_dsc.bg_opa = lv.OPA.TRANSP
        rect_dsc.border_color = self.legend_color
        rect_dsc.bg_color = lv_colors.BLACK
        rect_dsc.border_width = 1

        # draw the outline, tock marks, legend and value text

        self.canvas.draw_rect(0, 0, self.width, self.height, rect_dsc)
        if self.divisions > 0:
            dy = (self.height - 4) / self.divisions  # Tick marks
            # print("dy: ",dy)
            for tick in range(self.divisions + 1):
                ypos = int(dy * tick)
                p1.x = self.width // 5
                p1.y = ypos + 2
                p2.x = p1.x + self.width - 2 * self.width // 5
                p2.y = p1.y
                self.canvas.draw_line(point_array, 2, self.hline_dsc)

                # print("tick: %d, pos: %d"%(tick,p1.y))

                if legend:
                    label = lv.label(self.container)
                    label.align(self.canvas, lv.ALIGN.OUT_RIGHT_TOP, 5,
                                ypos - 5)
                    label.set_text(legend[self.divisions - tick])
                    label.add_style(lv.label.PART.MAIN, text_style)
        self.base = p1.y

        # draw the value rectangle
        # print("max: ",self.max_value)
        value_y = round(
            (self.height - 4) / (self.max_value - self.min_value) * self.value)
        rect_dsc.bg_color = self.bar_color
        rect_dsc.bg_opa = lv.OPA.COVER
        rect_dsc.border_width = 0
        # print("Pos of last tick: ",p1.y)
        # print("bar height: ",value_y)
        self.canvas.draw_rect(self.width // 5 + 5, self.base - value_y,
                              2 * self.width // 5, value_y, rect_dsc)
Example #13
0
def testlines(canvas, color):
    print("Test lines")
    p1 = lv.point_t()
    p2 = lv.point_t()
    line_dsc = lv.draw_line_dsc_t()
    line_dsc.init()
    line_dsc.color = color
    line_dsc.opa = lv.OPA.COVER

    clear()

    # from top left corner
    for x in range(0, CANVAS_WIDTH, 6):
        p1.x = 0
        p1.y = 0
        p2.x = x
        p2.y = CANVAS_HEIGHT - 1
        point_array = [p1, p2]
        canvas.draw_line(point_array, 2, line_dsc)

    for y in range(0, CANVAS_HEIGHT, 6):
        p2.x = CANVAS_WIDTH - 1
        p2.y = y
        canvas.draw_line(point_array, 2, line_dsc)
    time.sleep(1)
    clear()

    # from bottom left corner
    for x in range(0, CANVAS_WIDTH, 6):
        p1.x = 0
        p1.y = CANVAS_HEIGHT - 1
        p2.x = x
        p2.y = 0
        canvas.draw_line(point_array, 2, line_dsc)

    for y in range(0, CANVAS_HEIGHT, 6):
        p2.x = CANVAS_WIDTH - 1
        p2.y = y
        canvas.draw_line(point_array, 2, line_dsc)

    time.sleep(1)
    clear()

    # from bottom right corner
    for x in range(0, CANVAS_WIDTH, 6):
        p1.x = CANVAS_WIDTH - 1
        p1.y = CANVAS_HEIGHT - 1
        p2.x = x
        p2.y = 0
        canvas.draw_line(point_array, 2, line_dsc)

    for y in range(0, CANVAS_HEIGHT, 6):
        p2.x = 0
        p2.y = y
        canvas.draw_line(point_array, 2, line_dsc)

    time.sleep(1)
    clear()

    # from top right corner
    for x in range(0, CANVAS_WIDTH, 6):
        p1.x = CANVAS_WIDTH - 1
        p1.y = 0
        p2.x = x
        p2.y = CANVAS_HEIGHT - 1
        canvas.draw_line(point_array, 2, line_dsc)

    for y in range(0, CANVAS_HEIGHT, 6):
        p2.x = 0
        p2.y = y
        canvas.draw_line(point_array, 2, line_dsc)
Example #14
0
def test(canvas):
    """Test code."""
    print('display started')

    clear(lv_colors.GREEN)
    sleep(1)

    clear()

    p1 = lv.point_t()
    p2 = lv.point_t()
    point_array = [p1, p2]

    line_dsc = lv.draw_line_dsc_t()
    line_dsc.init()
    line_dsc.color = lv_colors.MAGENTA
    line_dsc.opa = lv.OPA.COVER

    p1.x = 10
    p1.y = CANVAS_HEIGHT - 1
    p2.x = p1.x + CANVAS_WIDTH // 2
    p2.y = p1.y
    canvas.draw_line(point_array, 2, line_dsc)
    sleep(1)

    p1.y = 0
    p2.x = p1.x
    p2.y = CANVAS_HEIGHT - 1
    line_dsc.color = lv_colors.CYAN
    canvas.draw_line(point_array, 2, line_dsc)
    sleep(1)

    rect_dsc = lv.draw_rect_dsc_t()
    rect_dsc.init()
    rect_dsc.bg_opa = lv.OPA.COVER
    rect_dsc.bg_color = lv_colors.WHITE

    canvas.draw_rect(round(CANVAS_WIDTH / 5.56), round(CANVAS_HEIGHT / 2.56),
                     round(CANVAS_WIDTH / 4.2), round(CANVAS_HEIGHT / 1.7),
                     rect_dsc)
    sleep(1)

    p1.x = 0
    p1.y = 0
    p2.x = CANVAS_WIDTH - 1
    p2.y = p1.y
    line_dsc.color = lv_colors.RED
    canvas.draw_line(point_array, 2, line_dsc)

    sleep(1)
    p1.x = CANVAS_WIDTH - 1
    p1.y = 0
    p2.x = CANVAS_WIDTH // 2
    p2.y = CANVAS_HEIGHT
    line_dsc.color = lv_colors.YELLOW
    canvas.draw_line(point_array, 2, line_dsc)
    sleep(1)
    clear()

    coords = [{
        "x": 0,
        "y": round(CANVAS_WIDTH * 0.65)
    }, {
        "x": round(CANVAS_WIDTH * 0.52),
        "y": round(CANVAS_HEIGHT * 0.83)
    }, {
        "x": round(CANVAS_WIDTH * 0.95),
        "y": round(CANVAS_HEIGHT * 0.96)
    }, {
        "x": round(CANVAS_WIDTH * 0.41),
        "y": round(CANVAS_HEIGHT * 0.52)
    }, {
        "x": round(CANVAS_WIDTH * 0.61),
        "y": round(CANVAS_HEIGHT * 0.15)
    }, {
        "x": 0,
        "y": round(CANVAS_HEIGHT * 0.65)
    }]

    draw_lines(canvas, coords, lv_colors.YELLOW)
    sleep(1)
    clear()

    offset = (CANVAS_WIDTH - CANVAS_HEIGHT) // 2
    sides = 7
    rotate = 0
    x0 = CANVAS_HEIGHT // 2  # center position
    y0 = x0
    r = 3 * CANVAS_HEIGHT // 8  # radius
    theta = radians(rotate)
    n = sides + 1
    point_array = []
    for s in range(n):
        t = 2.0 * pi * s / sides + theta
        point = lv.point_t()
        point.x = int(r * cos(t) + x0) + offset
        point.y = int(r * sin(t) + y0)
        point_array.append(point)

        # coords.append([int(r * cos(t) + x0), int(r * sin(t) + y0)])

    rect_dsc.bg_color = lv_colors.GREEN
    canvas.draw_polygon(point_array, 8, rect_dsc)
    rect_dsc.bg_color = lv_colors.RED
    canvas.draw_rect(0, 0, 30, 239, rect_dsc)
    sleep(1)
    '''