Advertisement
here2share

# Tk_wavy_wireframe.py

Jun 12th, 2019
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.12 KB | None | 0 0
  1. # Tk_wavy_wireframe.py
  2.  
  3. import math
  4. import time
  5. from Tkinter import *
  6. import random
  7.  
  8. root = Tk()
  9. width,height=680,680
  10. root.geometry("%dx%d+-10+0"%(width,height))
  11. canvas = Canvas(root,width=width, height=height, background="grey" )
  12. canvas.grid()
  13.  
  14. m = 10
  15. n = 10
  16. d = 20
  17. r = 20
  18. p = 60
  19. color = 'blue'
  20.  
  21. px = 50
  22. py = 50
  23.  
  24. k = 0
  25. angles = 360.0 / (m*n)
  26. spots = []
  27. lines = []
  28. for i in range(m):
  29.     xx = []
  30.     yy = []
  31.     v = k/10
  32.     for j in range(n):
  33.         x = px+(i*p)
  34.         y = py+(j*p)
  35.         spots += [[k,x,y]]
  36.         xx.append(k)
  37.         yy.append(v)
  38.         k += 1
  39.         v += 10
  40.     lines.extend([xx,yy])
  41. 0
  42. amount = len(spots)
  43. while 1:
  44.     canvas.delete('all')
  45.     plot = []
  46.     for i in range(amount):
  47.         j,x,y = spots[i]
  48.         angle = j * angles
  49.         u = r * math.sin(angle*math.pi/180)
  50.         v = r * math.cos(angle*math.pi/180)
  51.         k = (j+1-(i*0.03))%amount
  52.         spots[i] = [k,x,y]
  53.         x += u
  54.         y += v
  55.         plot += [(x,y)]
  56.     for line in lines:
  57.         p = [plot[i] for i in line]
  58.         canvas.create_line(p, fill=color)
  59.     canvas.update()
  60. 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement