Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_Sierpinski_Triangle_Random.py
- from Tkinter import *
- import random, time
- ww = 400
- hh = 400
- root = Tk()
- root.title("Tk Sierpinski Triangle Random")
- root.geometry("%dx%d+0+0"%(ww,hh))
- canvas = Canvas(root, width=ww, height=hh)
- canvas.pack()
- x0, y0 = 200, 50
- x1, y1 = 50, 300
- x2, y2 = 350, 300
- sierpinski = ((x0, y0), (x1, y1), (x2, y2))
- x, y = 0, 0
- for _ in range(100000):
- i = random.randint(0, 2)
- x = (sierpinski[i][0] + x) / 2
- y = (sierpinski[i][1] + y) / 2
- canvas.create_rectangle((x,y,x,y), fill='black', outline='')
- canvas.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement