Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_speed_of_graphics2.py
- from Tkinter import *
- from PIL import Image, ImageTk
- import random
- from time import clock
- root = Tk()
- root.title("Speed of Graphics 2 on 500x500 per Pixel")
- root.geometry("500x500")
- wi = 500
- he = 500
- w = Canvas(root, width=wi, height=he)
- w.pack()
- def data_process(y):
- xy.extend([(y/2,random.randrange(255),0) for x in range(wi)]) # set the color accordingly
- #
- xy = []
- for y in range(he):
- data_process(y)
- img = Image.new( 'RGB', (wi,he))
- c = 40 # Should be at least 40 frames per second for a 2560x1440 screen
- start = clock()
- while c:
- for y in range(he):
- t = y*wi
- t2 = xy[t:t+wi]
- random.shuffle(t2)
- xy[t:t+wi] = t2
- img.putdata(tuple(xy))
- imgTk = ImageTk.PhotoImage(img)
- w.create_image(0, 0, anchor=NW, image=imgTk)
- root.update()
- c = c - 1
- #
- t = int((clock()-start)*((2560*1440)/((wi*he)*1.0)))
- if t:
- print("Needs To Be At Least %dx Faster"%t)
- else:
- print("Congratulation... Minimal Speed Exceeded!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement