Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # tk_400x400_putdata_max_speed_test.py
- import tkinter as tk
- from PIL import Image, ImageTk
- import math
- ww = 400
- hh = 400
- root = tk.Tk()
- root.title("tk_400x400_putdata_max_speed_test")
- root.geometry("%dx%d+0+0"%(ww,hh))
- canvas = tk.Canvas(root, bg='white', width=ww, height=hh)
- canvas.pack()
- def draw():
- img.putdata(art)
- photo = ImageTk.PhotoImage(img)
- canvas.create_image(0,0,image=photo,anchor='nw')
- canvas.update()
- rgb = []
- def create_rgb():
- t = list(range(0, 256, 15))
- rrr = t[:]
- ggg = t[:]
- bbb = t[:]
- r = g = b = 0
- while 1:
- for r in rrr:
- for g in ggg:
- for b in bbb:
- if (r,g,b) not in rgb:
- rgb.append((r,g,b))
- else:
- return
- if bbb.index(b) == len(bbb) - 1:
- bbb = bbb[::-1]
- if ggg.index(g) == len(ggg) - 1:
- ggg = ggg[::-1]
- rrr = rrr[::-1]
- create_rgb()
- art = [(0, 0, 0)] * (ww * hh)
- art = art[:]
- img = Image.new('RGB', (ww, hh), (0, 0, 0))
- i = 0
- xy = {}
- for x in range(0, ww):
- for y in range(0, hh):
- xy[x,y] = i
- i += 1
- while True:
- pixels = rgb[:]
- for pixel in pixels:
- for x in range(0, ww):
- for y in range(0, hh):
- art[xy[x, y]] = pixel
- draw()
Add Comment
Please, Sign In to add comment