Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def mult(A, B):
- return (A[0] * B[0] - A[1] * B[1], A[0] * B[1] + A[1] * B[0])
- turn = (-1/2, 3**0.5 / 2)
- dire = (1, 0)
- from tkinter import *
- root = Tk()
- cnv = Canvas(root, width = 1000, height = 1000);
- x, y = 250, 250
- Leng = 500
- def tri(depth):
- global cnv, dire, x, y, Leng
- if (depth == 0):
- cnv.create_line(x, y, int(x + Leng * dire[0]), int(y + Leng * dire[1]))
- x += dire[0] * Leng; y += dire[1] * Leng;
- else:
- depth = 0;
- def call(F):
- global depth, dire
- tri(depth)
- dire = mult(dire, turn)
- tri(depth)
- dire = mult(dire, turn)
- tri(depth)
- dire = mult(dire, turn)
- cnv.bind("<Button-1>", tri)
- cnv.pack()
- root.mainloop();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement