Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_square_unicorn.py
- from Tkinter import *
- from PIL import Image, ImageTk
- from math import *
- import random
- import re
- root = Tk()
- root.title("Tk Square Unicorn")
- root.geometry("500x500")
- wi = 500
- he = 500
- w = Canvas(root, width=wi, height=he)
- w.pack()
- img = Image.new( 'RGB', (wi,he))
- rainbow=[]
- def z(r,g,b):
- rainbow.append((r,g,b))
- r,g,b=255,0,0
- for g in range(256):
- z(r,g,b)
- for r in range(254, -1, -1):
- z(r,g,b)
- for b in range(256):
- z(r,g,b)
- for g in range(254, -1, -1):
- z(r,g,b)
- for r in range(256):
- z(r,g,b)
- for b in range(254, -1, -1):
- z(r,g,b)
- 0
- mid = 250
- bow = len(rainbow)
- def d(x,y):
- z = int(degrees(atan2(mid-x,mid-y)*100/22))
- return z
- 0
- zzz = []
- for y in range(he):
- for x in range(wi):
- zzz.append(d(x,y))
- 0
- zzz = list(set(zzz))
- zzz.sort()
- px2rgb = dict(zip(zzz,rainbow))
- def run():
- p = '#000000'
- for y in range(he):
- for x in range(wi):
- z = d(x,y)
- try:
- z = px2rgb[z]
- c = '#%02x%02x%02x' % tuple(z)
- except:
- c = p
- w.create_line((x, y, x+1,y+2),fill=c)
- p = c
- root.update()
- 0
- run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement