Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # tk_flippant_lines.py
- import tkinter as tk
- w, h = 240, 136
- speed_multiplier = 0.5
- num_speeds = 30
- speeds = [speed_multiplier * (0.5 + i / (num_speeds - 1) * 4.0) for i in range(num_speeds)]
- l = [[w//15*j, speeds[i%num_speeds], w//15*j, speeds[(i+1)%num_speeds]] for i, j in enumerate(range(15))]
- c = ['#000', '#1D2B53', '#7E2553', '#008751', '#AB5236', '#5F574F', '#C2C3C7', '#FFF1E8', '#F00', '#FA0', '#FF0', '#0F0', '#0AF', '#83769C', '#F7A', '#FCA']
- rr = tk.Tk()
- cv = tk.Canvas(rr, width=w, height=h, bg='black')
- cv.pack()
- while 1:
- cv.delete("all")
- for a, b in enumerate(l):
- for i in (0, 2):
- b[i] += b[i+1]
- if b[i] < 0 or b[i] > w: b[i+1] *= -1
- cv.create_line(b[0], 0, b[2], h, width=3, fill=c[(a + 1) % 16])
- cv.update()
- rr.update_idletasks()
Advertisement
Add Comment
Please, Sign In to add comment