# Tessellations program # starter code from codex import * my_colors = [RED, BLUE, GREEN, PINK, ORANGE, MAGENTA, YELLOW, DARK_GREEN, CYAN, PURPLE, WHITE] # define a brick def brick(x, y, color): display.fill_rect(x, y, 50, 20, color) display.draw_rect(x, y, 50, 20, WHITE) def skew(x, y, color): display.fill_rect(x, y, 50, 20, color) display.fill_rect(x+25, y+20, 50, 20, color) def halfcross(x, y, color): display.fill_rect(x, y+20, 20, 20, color) display.fill_rect(x+20, y, 20, 60, color) def triangle(x, y, color): display.draw_line(x, y, x+60, y, color) display.draw_line(x, y, x+30, y+30, color) display.draw_line(x+30, y+30, x+60, y, color) def flipped(x, y, color): pass def my_shape(x, y, color): pass def tessell_bricks(x, y, index): for column in range(5): brick(x, y, my_colors[index]) x = x + 50 index = index + 1 if index == len(my_colors): index = 0 def tessell_skew(x, y, index): skew(x, y, my_colors[index]) def tessell_halfcross(x, y, index): halfcross(x, y, my_colors[index]) def tessell_triangle(x, y, index): triangle(x, y, my_colors[index]) def tessell_my_shape(x, y, index): my_shape(x, y, my_colors[index]) def menu(): display.clear() display.print("--Menu--") display.print("A - bricks") display.print() display.print("A to begin") while True: if buttons.was_pressed(BTN_A): break # Main program menu() while True: if buttons.was_pressed(BTN_A): display.clear() tessell_bricks(0, 0, 0) if buttons.was_pressed(BTN_B): display.clear() tessell_skew(0, 0, 0) if buttons.was_pressed(BTN_R): display.clear() tessell_halfcross(0, 0, 0) if buttons.was_pressed(BTN_L): display.clear() tessell_triangle(0, 0, 0) if buttons.was_pressed(BTN_U): display.clear() tessell_my_shape(0, 0, 0) # break out of the loop and end the program if buttons.was_pressed(BTN_D): break # Program end display.clear() display.print("The end")