Advertisement
here2share

# Tk_trippy_chessboard.py

Oct 1st, 2019
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. # Tk_trippy_chessboard.py
  2.  
  3. from Tkinter import *
  4. from PIL import Image, ImageTk
  5. from math import *
  6. import random
  7.  
  8. root = Tk()
  9. root.title("Tk trippy chessboard")
  10. root.geometry("500x500")
  11. wi = 500
  12. he = 500
  13. w = Canvas(root, width=wi, height=he)
  14. w.pack()
  15.  
  16. img = Image.new( 'RGB', (wi,he))
  17. cols = {}
  18. xy = []
  19.  
  20. DIM = 500    
  21.  
  22. def r(i, j):
  23.     i+=sin(4*pi*j/DIM)*DIM/100;i=max(1,min(i,DIM-1))
  24.     return int(ceil(4+sin(8*pi*i/DIM)*sin(8*pi*j/DIM)*3)*32)
  25.  
  26. def g(i, j):
  27.     return int(r(i,j))
  28.  
  29. def b(i, j):
  30.     return int(r(i,j)-cos(4*pi*i/DIM)*16)
  31.  
  32. for y in range(DIM):
  33.     for x in range(DIM):
  34.         c = '#%02x%02x%02x' % (r(x, y),g(x, y),b(x, y))
  35.         w.create_line((x, y, x+1,y+2),fill=c)
  36. root.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement