Advertisement
Guest User

lissajous curve generator

a guest
Oct 14th, 2016
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. from Tkinter import *
  2. from math import sin, cos
  3. width = 640
  4. height = 480
  5. w = Canvas(Tk(), width=width, height=height)
  6. w.pack()
  7. t = 0.0
  8. step = 1
  9. a = 10.5
  10. b = 11
  11. def pos(t):
  12.     x = width/2 + (width * sin( t/a )) * 0.49
  13.     y = height/2 + (height * cos( t/b )) * 0.49
  14.     return x, y
  15. def draw(t):
  16.     p1, p2 = pos(t), pos(t + step)
  17.     w.create_line(p1[0], p1[1], p2[0], p2[1])
  18. while 1:
  19.     draw(t)
  20.     t += step
  21.     w.update()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement