Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_Gradient_Art_Generator.py
- from tkinter import *
- from PIL import Image, ImageTk
- import random
- import math
- root = Tk()
- root.title("Gradient Art Generator")
- wt = 400
- ht = 400
- root.geometry("%dx%d+-10+0"%(wt,ht))
- canvas = Canvas(root, width=wt, height=ht)
- canvas.pack()
- def art_gen(w,h):
- xy = []
- for x in range(w):
- for y in range(h):
- z = random.randint(-300,1600)
- z = min(255,max(0,z))
- xy.append([(x,y),z])
- xy = dict(xy)
- px = 128
- for cx in range(w):
- for cy in range(h):
- z = xy[(int(cx/10), cy)]
- px = (px*20+z)/21.0
- rgb[cx][cy].append(int(px))
- 0
- while 1:
- rgb = [[[] for x in range(wt)] for y in range(ht)]
- [art_gen(wt,ht) for z in 'rgb']
- rgb = tuple([tuple(i) for z in rgb for i in z])
- img = Image.new('RGB', (wt,ht))
- img.putdata(rgb)
- imgTk = ImageTk.PhotoImage(img)
- canvas.create_image(0, 0, anchor=NW, image=imgTk)
- root.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement