Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Tk_spiral_gen.py
- from Tkinter import *
- import math
- def spiral_gen(radius, step, resolution=.1, start=0.0, angle=0.0):
- dist = start+0.0
- coords=[]
- while dist*math.hypot(math.cos(angle),math.sin(angle))<radius:
- x = int(dist*math.cos(angle))
- y = int(dist*math.sin(angle))
- if [x,y] not in coords:
- coords.append([x,y])
- dist+=step
- angle+=resolution
- return coords
- root = Tk()
- root.title("Spiral Generator")
- c_width = 600
- c_height = 600
- canvas = Canvas(root, width=c_width, height=c_height, bg='white')
- canvas.pack()
- spiral = spiral_gen(250, 0.02, 0.005, 20)
- for x,y in spiral:
- x += c_width/2
- y += c_height/2
- canvas.create_oval(x, y, x+1, y+1, fill="red")
- canvas.update()
- print(spiral)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement