Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_star_pattern.py
- from Tkinter import *
- import math
- import random
- import time
- root = Tk()
- c_width = 600
- c_height = 600
- canvas = Canvas(root, width=c_width, height=c_height, bg='white')
- canvas.pack()
- starXY = [c_width/2,c_height/2]
- def star_pattern(points, innerRadius, outerRadius):
- points *= 2
- segments = (math.pi * 2.0) / points
- radiusChoice = [innerRadius, outerRadius]
- star = []
- switch = [0,1]
- for point in range(points):
- r = radiusChoice[switch[-1]]
- omega = segments * point
- star.append(((r * -math.sin(omega)) + starXY[0], (r * -math.cos(omega)) + starXY[1]))
- switch += [switch.pop(0)]
- return star
- wait = 0
- while 1:
- outer = 270
- color = '#%02x%02x%02x' % (180, 0, 180)
- for points in range(3,30):
- for inner in range(20,min(240,100+points*3)):
- canvas.create_polygon(star_pattern(points,inner,outer), fill=color)
- #time.sleep(0.2)
- canvas.update()
- canvas.delete('all')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement