Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # pixel_pooling.py -- from generic_multiprocessing.py as a graphic speed test
- from multiprocessing.pool import ThreadPool
- import multiprocessing
- import time
- import random
- wi = 120
- he = 80
- from Tkinter import *
- root = Tk()
- root.geometry("%sx%s" % (wi,he))
- root.title("Pixel Pooling")
- w = Canvas(root, bg="white")
- w.pack()
- rgb = {}
- fff = {}
- def p(z):
- return random.randrange(90,165)+z/1.8
- for z in range(he):
- rgb[z] = {'r':p(z),'g':p(z),'b':p(z)}
- fff[z] = {'r':1,'g':2,'b':3}
- def draw_data(y):
- rgbX = 'r g b'.split()
- random.shuffle(rgbX)
- for x in range(wi):
- c = '#'
- for z in rgbX:
- if rgb[y][z] < 80 or rgb[y][z] > 175:
- fff[y][z] *= -1
- rgb[y][z] += fff[y][z]
- v = int(rgb[y][z])
- c += '%02x' %(v)
- w.create_line(x,y,x+1,y+1,fill=c,tags="tmp")
- pool = ThreadPool(120)
- while 1:
- w.delete("tmp")
- pool.map(draw_data, range(he))
- root.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement