Skip to content

Instantly share code, notes, and snippets.

@alexeytal
Created October 21, 2016 14:27
Show Gist options
  • Save alexeytal/0cb5669eaa04f480997dcc4290a477c6 to your computer and use it in GitHub Desktop.
Save alexeytal/0cb5669eaa04f480997dcc4290a477c6 to your computer and use it in GitHub Desktop.
random_fibonacci_circles.py
from Tkinter import Tk, Canvas
import random
root = Tk()
canvas_size = 500
canv = Canvas(root, width = canvas_size, height = canvas_size, bg = 'white')
canv.pack()
def draw_circle(event):
global count,radius
r=radius
x = random.randint(0, canvas_size - r*2)
y = random.randint(0, canvas_size - r*2)
canv.create_oval(x, y, x + r*2, y + r*2, fill='blue')
count+=1
radius=F(count)
def F(n):
if n == 0: return 0
elif n == 1: return 1
else: return F(n-1)+F(n-2)
count=1
radius=F(1)
canv.bind('<ButtonPress>', draw_circle)
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment