Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_basic_color_patterns.py
- from tkinter import *
- from PIL import Image, ImageTk
- import math
- from itertools import combinations
- ww = 600
- hh = 600
- sz = 5
- root = Tk()
- root.geometry("%dx%d+0+0"%(ww,hh))
- canvas = Canvas(root, width=ww, height=hh)
- canvas.pack()
- seq = 1 # sequences
- colors = 'red orange yellow green blue purple'.split()*(600*4)
- L = len(colors)
- rgb = []
- xy = []
- for y in range(0,hh,sz):
- for x in range(0,ww,sz):
- xy += [(x,y)]
- rgb += [0]
- Lxy = len(rgb)
- i = 0
- while 1:
- print (seq)
- seq += 1
- canvas.delete('all')
- for k in range(Lxy):
- color = colors[0]
- colors.insert(L-i, colors.pop(0))
- i = (i-1)%99
- x,y = xy[k]
- canvas.create_rectangle((x, y, x-sz, y+sz), fill=color, width=0)
- canvas.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement