Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_central_pop_art.py
- from math import cos,sin,pi,radians
- import random
- r=random.randint
- try:
- import tkinter as tk
- except:
- import Tkinter as tk
- root=tk.Tk()
- root.title("Tk Central Pop Art")
- ww=640
- hh=640
- mid=(ww+hh)/4
- canvas=tk.Canvas(root,width=ww,height=hh)
- canvas.pack(fill="both",expand=True)
- class Cv(): 0
- cv=Cv()
- cv.color=''
- COLORS = 'red darkorange yellow green blue purple'.split()
- cv.x=0
- cv.y=0
- cv.a=1
- cv.b=1
- cv.a2=1
- cv.b2=1
- cv.o360=360
- cv.angle2=0
- cv.start=0
- cv.count=0
- STEP=25
- def mark():
- a=cv.a*STEP
- b=a+(cv.b*STEP)
- c=360.0/cv.o360
- angle = cv.start
- for null in range(0,360,int(c)):
- angle += c
- angle = angle%360
- x0=cv.x+cos(radians(angle))*a
- y0=cv.y+sin(radians(angle))*a
- x1=cv.x+cos(radians(angle))*b
- y1=cv.y+sin(radians(angle))*b
- canvas.create_line(x0,y0,x1,y1,width=5,fill=cv.color)
- def tick():
- #canvas.delete(tk.ALL)
- c2s = r(5,60)
- cv.x,cv.y=[r(0,640) for z in 'zz']
- cv.b=r(1,15)
- cv.a=r(1,16-cv.b)
- cv.angle2=r(0,360)
- cv.start=r(0,360)
- cv.o360=c2s
- try:
- cv.color=cv.colors2.pop()
- except:
- cv.colors2 = COLORS[:]
- cv.color=cv.colors2.pop()
- mark()
- canvas.after(1,tick)
- tick()
- tk.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement