Advertisement
Velvet_remedy

Untitled

Apr 22nd, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. from math import *
  2. from tkinter import *
  3.  
  4. w = 800
  5. h = 500
  6. root = Tk()
  7. canv = Canvas(root, width=w, height=h, bg="lightpink")
  8.  
  9.  
  10. def snowflake(x, y, r):
  11. x1 = x + r
  12. y1 = y
  13. cos = 2 ** 0.5 / 2
  14. sin = 2 ** 0.5 / 2
  15. x2 = x + r * cos
  16. y2 = y - r * sin
  17. x3 = x
  18. y3 = y - r
  19. x4 = x - r * cos
  20. y4 = y - r * sin
  21. x5 = x - r
  22. y5 = y
  23. x6 = x - r * cos
  24. y6 = y + r * sin
  25. x7 = x
  26. y7 = y + r
  27. x8 = x + r * cos
  28. y8 = y + r * sin
  29.  
  30. canv.create_line(x5, y5, x1, y1, width=2)
  31. canv.create_line(x6, y6, x2, y2, width=2)
  32. canv.create_line(x7, y7, x3, y3, width=2)
  33. canv.create_line(x8, y8, x4, y4, width=2)
  34. return [[x1, y1], [x2, y2], [x3, y3], [x4, y4], [x5, y5], [x6, y6], [x7, y7], [x8, y8]]
  35.  
  36.  
  37. centr = [[200,200]]
  38. otv = []
  39. r=100
  40. n = int(input())
  41. for i in range(n):
  42. for j in range(len(centr)):
  43. otv+=snowflake(centr[j][0], centr[j][1], r)
  44. centr = otv
  45. r/=3
  46. canv.pack()
  47. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement