Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_trippy_chessboard.py
- from Tkinter import *
- from PIL import Image, ImageTk
- from math import *
- import random
- root = Tk()
- root.title("Tk trippy chessboard")
- root.geometry("500x500")
- wi = 500
- he = 500
- w = Canvas(root, width=wi, height=he)
- w.pack()
- img = Image.new( 'RGB', (wi,he))
- cols = {}
- xy = []
- DIM = 500
- def r(i, j):
- i+=sin(4*pi*j/DIM)*DIM/100;i=max(1,min(i,DIM-1))
- return int(ceil(4+sin(8*pi*i/DIM)*sin(8*pi*j/DIM)*3)*32)
- def g(i, j):
- return int(r(i,j))
- def b(i, j):
- return int(r(i,j)-cos(4*pi*i/DIM)*16)
- for y in range(DIM):
- for x in range(DIM):
- c = '#%02x%02x%02x' % (r(x, y),g(x, y),b(x, y))
- w.create_line((x, y, x+1,y+2),fill=c)
- root.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement