def draw_dots(turt: RawTurtle) -> None: penstate = turt.pen() turt.penup() for x, y in DIGIT2POS.values(): turt.setheading(turt.towards(x, y)) turt.goto(x, y) turt.dot() turt.pen(pen = penstate)
def draw_pattern(turt: RawTurtle, pattern: str) -> None: penstate = turt.pen() turt.penup() for x, y in map(lambda digit: DIGIT2POS[digit], pattern): turt.setheading(turt.towards(x, y)) turt.goto(x, y) turt.pendown() turt.dot() turt.pen(pen = penstate)
def draw(ans): """Вывод топологической схемы""" global xax, moves, oboz, window turx, tury = xax - int(xax*0.3), int(yax*0.25) bg_def = window.cget('bg') canvas = Canvas(window, relief='sunken', borderwidth=5, width=turx, height=tury, background=bg_def) canvas.place(relx=0.5, rely=0.1, y=int(yax*0.19), anchor=CENTER) screen = TurtleScreen(canvas) global turtle turtle = RawTurtle(canvas) turtle.speed(5) turtle.hideturtle() allen = (turx - int(xax*0.2)) global let if len(ans) > 7: if ans[5] == 1 and ans[8] == 1: let = allen // 3 else: if ans[5] == 1: let = allen // 4 elif ans[8] == 1: let = allen // 4 else: let = allen // 5 if ans[5] == 2: allen -= let//2 if ans[8] == 2: allen -= let//2 else: if ans[5] == 1: let = allen // 2 else: let = allen // 3 if ans[5] == 2: allen -= let//2 turtle.color('white') turtle.up() turtle.goto(x=-allen // 2, y=-int(yax*0.09)) turtle.down() turtle.color('black') turtle.dot(5, 'black') turtle.write('A') for i in [moves[k + 1][x] for k, x in enumerate(ans) if k + 1 in moves]: print(i) eval(i)
from turtle import Screen, RawTurtle screen = Screen() turtle = RawTurtle(screen) ### Traje turtle.shape("turtle") ## Tamaño del punto y color turtle.dot(5, "green") turtle.fd(50) turtle.dot(5, "red") turtle.lt(120)## Gira a la izquierda turtle.fd(100)## Avanza 100 turtle.dot(5, "blue") turtle.lt(170) turtle.fd(150) turtle.lt(170) screen.mainloop() ## La pantalla espera un evento...
from turtle import Screen, RawTurtle screen = Screen() turtle = RawTurtle(screen) ### Traje turtle.shape("turtle") ## Tamaño del punto y color turtle.pu() turtle.dot(7, "red") turtle.fd(40) turtle.pd() turtle.rt(90) turtle.fd(40) turtle.dot(5, "red") turtle.rt(90) turtle.fd(80) turtle.dot(5, "red") turtle.rt(90) turtle.fd(80) turtle.dot(5, "red") turtle.rt(90) turtle.fd(80) turtle.dot(5, "red")