Advertisement
here2share

# Tk_wavy_wireframe2.py

Jun 19th, 2019
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.16 KB | None | 0 0
  1. # Tk_wavy_wireframe2.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 = 20
  15. n = 20
  16. p = 30
  17. color = 'blue'
  18.  
  19. px = 50
  20. py = 50
  21.  
  22. k = 0
  23. angles = 360.0 / (m*n)
  24. spots = []
  25. lines = []
  26. for i in range(m):
  27.     xx = []
  28.     yy = []
  29.     v = k/20
  30.     for j in range(n):
  31.         x = px+(i*p)
  32.         y = py+(j*p)
  33.         spots += [[k,x,y]]
  34.         xx.append(k)
  35.         yy.append(v)
  36.         k += 1
  37.         v += 20
  38.     lines.extend([xx,yy])
  39. 0
  40. amount = len(spots)
  41. speeds = [(i*0.025) for i in range(amount+1)]
  42. while 1:
  43.     canvas.delete('all')
  44.     plot = []
  45.     for i in range(amount):
  46.         j,x,y = spots[i]
  47.         k = (j+1-(speeds[i]))%amount
  48.         spots[i] = [k,x,y]
  49.         angle = j * angles
  50.         u = ((amount-i)*0.04) * math.sin(angle*math.pi/180)
  51.         v = ((amount-i)*0.03) * math.cos(angle*math.pi/180)
  52.         x += u
  53.         y += v
  54.         u = (i*0.04) * math.sin(angle*math.pi/180)
  55.         v = (i*0.03) * math.cos(angle*math.pi/180)
  56.         x += u
  57.         y += v
  58.         plot += [(x,y)]
  59.     for line in lines:
  60.         p = [plot[i] for i in line]
  61.         canvas.create_line(p, fill=color)
  62.     canvas.update()
  63. 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement