Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_tablecloth_ripple.py
- from Tkinter import *
- from PIL import Image, ImageTk
- from math import *
- import random
- root = Tk()
- root.title("Tk Tablecloth Ripple")
- 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):
- s=3./(j+120)
- y=(j+sin((i*i+sqrt(j))/100./DIM)*100)*s
- return (int((i+DIM)*s+y)%2+int((DIM*2-i)*s+y)%2)*127
- def g(i, j):
- s=3./(j+120)
- y=(j+sin((i*i+sqrt(j))/100./DIM)*100)*s
- return (int(5*((i+DIM)*s+y))%2+int(5*((DIM*2-i)*s+y))%2)*127
- def b(i, j):
- s=3./(j+120)
- y=(j+sin((i*i+sqrt(j))/100./DIM)*100)*s
- return (int(20*((i+DIM)*s+y))%2+int(20*((DIM*2-i)*s+y))%2)*127
- for y in range(DIM):
- for x in range(DIM):
- c = '#%02x%02x%02x' % (int(r(x, y)),int(g(x, y)),int(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