Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. def mult(A, B):
  2. return (A[0] * B[0] - A[1] * B[1], A[0] * B[1] + A[1] * B[0])
  3. turn = (-1/2, 3**0.5 / 2)
  4. dire = (1, 0)
  5.  
  6. from tkinter import *
  7. root = Tk()
  8. cnv = Canvas(root, width = 1000, height = 1000);
  9.  
  10.  
  11. x, y = 250, 250
  12.  
  13.  
  14.  
  15. Leng = 500
  16.  
  17. def tri(depth):
  18. global cnv, dire, x, y, Leng
  19. if (depth == 0):
  20. cnv.create_line(x, y, int(x + Leng * dire[0]), int(y + Leng * dire[1]))
  21. x += dire[0] * Leng; y += dire[1] * Leng;
  22. else:
  23.  
  24.  
  25.  
  26.  
  27. depth = 0;
  28. def call(F):
  29. global depth, dire
  30. tri(depth)
  31. dire = mult(dire, turn)
  32. tri(depth)
  33. dire = mult(dire, turn)
  34. tri(depth)
  35. dire = mult(dire, turn)
  36.  
  37.  
  38. cnv.bind("<Button-1>", tri)
  39. cnv.pack()
  40. root.mainloop();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement