Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # quantum_cubes_4.py
- from Tkinter import *
- from random import *
- from math import cos, sin, radians
- ww = 720
- hh = 720
- tiles = (0.0, 0.0), (-0.866, -0.5), (0.0, -1.0), (0.866, -0.5)
- def create_tile():
- polygon = [(x*base, y*base) for (x,y) in tiles]
- polygon = [( xc+x*cos(radians(angle)) + y*sin(radians(angle)),
- yc+y*cos(radians(angle)) - x*sin(radians(angle)) )
- for (x,y) in polygon]
- cubes[t] = canvas.create_polygon(polygon, fill=color, outline="black", width=1)
- root = Tk()
- canvas = Canvas(root, width=ww, height=hh)
- canvas.pack(fill=BOTH)
- xc=360
- yc=360
- base=25
- b2=int(0.866*2*base)
- b3=b2/2
- cubes = {}
- points = []
- c=0
- c2=0
- t = 'bg'
- cubes[t] = {}
- sides = [
- ('red',0),
- ('green',120),
- ('blue',240),
- ]
- for yc in range(-base,hh,int(base*1.5)):
- for xc in range(-b2+(b3*(c%2)),ww+b2,b2):
- points += [(xc,yc)]
- c2+=1
- c+=1
- while 1:
- xc,yc = choice(points)
- color, angle = choice(sides)
- t = str([xc,yc,color])
- try:
- canvas.delete(cubes[t])
- del cubes[t]
- except:
- color, angle = choice(sides)
- create_tile()
- canvas.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement