Skip to content

Instantly share code, notes, and snippets.

@alexeytal
Created October 12, 2016 20:48
Show Gist options
  • Save alexeytal/87d4cfae52b1dcd7b10115cecd98441d to your computer and use it in GitHub Desktop.
Save alexeytal/87d4cfae52b1dcd7b10115cecd98441d to your computer and use it in GitHub Desktop.
from Tkinter import Tk, Canvas
import random
canvas_size = 500
x = 250
y = 250
delay = 10
colors = ["red","orange","yellow","green","blue","cyan","magenta","light blue"]
def step():
global x, color,y,i
i+=1
if i%30==0:
color=colors[i%8]
x += random.randint(-3, 3)
y += random.randint(-3, 3)
canvas.create_line([x, y], [x + 3, y], fill=color,width=16)
root.after(delay, step)
i=0
color='black'
root = Tk()
canvas = Canvas(root, width=canvas_size, height=canvas_size, background='black')
canvas.pack()
step()
root.mainloop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment