Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import *
- from tkinter import *
- w = 800
- h = 500
- root = Tk()
- canv = Canvas(root, width=w, height=h, bg="lightpink")
- def snowflake(x, y, r):
- x1 = x + r
- y1 = y
- cos = 2 ** 0.5 / 2
- sin = 2 ** 0.5 / 2
- x2 = x + r * cos
- y2 = y - r * sin
- x3 = x
- y3 = y - r
- x4 = x - r * cos
- y4 = y - r * sin
- x5 = x - r
- y5 = y
- x6 = x - r * cos
- y6 = y + r * sin
- x7 = x
- y7 = y + r
- x8 = x + r * cos
- y8 = y + r * sin
- canv.create_line(x5, y5, x1, y1, width=2)
- canv.create_line(x6, y6, x2, y2, width=2)
- canv.create_line(x7, y7, x3, y3, width=2)
- canv.create_line(x8, y8, x4, y4, width=2)
- return [[x1, y1], [x2, y2], [x3, y3], [x4, y4], [x5, y5], [x6, y6], [x7, y7], [x8, y8]]
- centr = [[200,200]]
- otv = []
- r=100
- n = int(input())
- for i in range(n):
- for j in range(len(centr)):
- otv+=snowflake(centr[j][0], centr[j][1], r)
- centr = otv
- r/=3
- canv.pack()
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement