import Image,ImageDraw,ImageFont,ImageTk,Tkinter,math,time
img=Image.new('RGB',(600,600))
draw = ImageDraw.Draw(img)
def drawcircles():
a=90
b=35
c=0
d=190
e=300
t=0
x=int(a*math.sin(b*t+c)+d*math.sin(t)+e)
y=int(a*math.cos(b*t+c)+d*math.cos(t)+e)
x0=x
y0=y
t+=0.01
while t<300:
x=int(a*math.sin(b*t+c)+d*math.sin(t)+e)
y=int(a*math.cos(b*t+c)+d*math.cos(t)+e)
col=int((math.sin(4*t)+1)*180)
draw.line((x0,y0,x,y), fill="hsl(%d,100%%,50%%)"%(col))
x0=x
y0=y
t+=0.01
tic=time.time()
drawcircles()
toc=time.time()-tic
draw.text((5,5), "%ds"%toc, fill=(155,155,155), font=ImageFont.truetype('simfang.ttf',22))
del draw
img.save("out.png")
def button_click_exit_mainloop (event):
event.widget.quit()
root = Tkinter.Tk()
root.bind("<Button>", button_click_exit_mainloop)
root.geometry('600x600')
tkpi = ImageTk.PhotoImage(file="out.png")
label_image = Tkinter.Label(root, image=tkpi)
label_image.pack()
root.mainloop()
img=Image.new('RGB',(600,600))
draw = ImageDraw.Draw(img)
def drawcircles():
a=90
b=35
c=0
d=190
e=300
t=0
x=int(a*math.sin(b*t+c)+d*math.sin(t)+e)
y=int(a*math.cos(b*t+c)+d*math.cos(t)+e)
x0=x
y0=y
t+=0.01
while t<300:
x=int(a*math.sin(b*t+c)+d*math.sin(t)+e)
y=int(a*math.cos(b*t+c)+d*math.cos(t)+e)
col=int((math.sin(4*t)+1)*180)
draw.line((x0,y0,x,y), fill="hsl(%d,100%%,50%%)"%(col))
x0=x
y0=y
t+=0.01
tic=time.time()
drawcircles()
toc=time.time()-tic
draw.text((5,5), "%ds"%toc, fill=(155,155,155), font=ImageFont.truetype('simfang.ttf',22))
del draw
img.save("out.png")
def button_click_exit_mainloop (event):
event.widget.quit()
root = Tkinter.Tk()
root.bind("<Button>", button_click_exit_mainloop)
root.geometry('600x600')
tkpi = ImageTk.PhotoImage(file="out.png")
label_image = Tkinter.Label(root, image=tkpi)
label_image.pack()
root.mainloop()