Toggle Navigation
Hatchery
Eggs
CityControlTest
custom_shapes.py
Users
Badges
Login
Register
custom_shapes.py
raw
Content
import display import wifi import utils def draw_menu_arrow(x, y): """ Draws an Arrow. Tip of the arrow will be at the point (x,y) and the arrow will be pointing to its right. Height is the height of the rectangular part, triangle part will be + a pixels and width will be the total width of the arrow. """ draw_right_arrow(x, y, 30, 6, True, color=0x9cff08) def draw_right_arrow(x, y, width, height, filled, color, window=None): """ Draws an Arrow. Tip of the arrow will be at the point (x,y) and the arrow will be pointing right. Height is half the height of the triangle part, width will be the total width of the arrow. """ a = x - width b = int(y - height/3) - 1 widthrect = int(width * 0.6) x0 = a + widthrect y0 = y - height y1 = y + height display.drawRect(a, b, widthrect, height, filled, color) display.drawTriangle(x0, y0, x0, y1, x, y, color) def draw_left_arrow(x, y, width, height, filled, color, window=None): """ Draws an Arrow. Tip of the arrow will be at the point (x,y) and the arrow will be pointing left. Height is the height of the rectangular part, triangle part will be + a pixels and width will be the total width of the arrow. """ widthrect = int(width * 0.6) a = int(x + width * 0.4) b = int(y - height/3) - 1 x0 = a y0 = y - height y1 = y + height display.drawRect(a, b, widthrect, height, filled, color) display.drawTriangle(x0, y0, x0, y1, x, y, color) def draw_up_arrow(x, y, height, width, filled, color, window=None): """ Draws an Arrow. Tip of the arrow will be at the point (x,y) and the arrow will be pointing up. Keep the same argument in the same order when calling this function as when using the left/Right functions. """ heightrect = int(height * 0.6) a = int (x - width/3) - 1 b = int (y + height * 0.4) x0 = x - width x1 = x + width y0 = int(y + height * 0.4) display.drawRect(a, b, width, heightrect, filled, color) display.drawTriangle(x0, y0, x1, y0, x, y, color) def draw_down_arrow(x, y, height, width, filled, color, window=None): """ Draws an Arrow. Tip of the arrow will be at the point (x,y) and the arrow will be pointing up. Keep the same argument in the same order when calling this function as when using the left/Right functions. """ heightrect = int(height * 0.6) a = int(x - width/3) - 1 b = y - height x0 = x - width x1 = x + width y0 = int(y - height * 0.4) display.drawRect(a, b, width, heightrect, filled, color) display.drawTriangle(x0, y0, x1, y0, x, y, color) def draw_code_arrow(x, y, action): if action == "UP": y = y - 15 draw_up_arrow(x, y, 30, 6, True, color=0x9cff08) elif action == "DOWN": y = y + 15 draw_down_arrow(x, y, 30, 6, True, color=0x9cff08) elif action == "RIGHT": x = x + 15 draw_right_arrow(x, y, 30, 6, True, color=0x9cff08) elif action == "LEFT": x = x - 15 draw_left_arrow(x, y, 30, 6, True, color=0x9cff08) def draw_wifi_indicator(x, y, color_fg, color_bg): circle_x = x + 20 circle_y = y + 23 display.drawCircle(circle_x, circle_y, 23, 315, 405, True, color_fg) display.drawCircle(circle_x, circle_y, 19, 305, 415, True, color_bg) display.drawCircle(circle_x, circle_y, 15, 315, 405, True, color_fg) display.drawCircle(circle_x, circle_y, 11, 305, 415, True, color_bg) display.drawCircle(circle_x, circle_y, 7, 315, 405, True, color_fg) if not wifi.status(): display.drawText(x + 25, y + 18, "X", 0xff0000, utils.ARCADE_FONT[8]) """ drawLeftArrow(100,80, 30, 6, True, color=0x9cff08) drawRightArrow(100,80, 30, 6, True, color=0x9cff08) drawUpArrow(100,80, 30, 6, True, color=0x9cff08) drawDownArrow(100,80, 30, 6, True, color=0x9cff08) """