Advertisement
here2share

# Tk_no_ones_radial_3.py

Feb 28th, 2022
1,153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.28 KB | None | 0 0
  1. # Tk_no_ones_radial_3.py
  2.  
  3. from Tkinter import *
  4. from math import sqrt, atan2
  5. from random import shuffle as rs
  6.  
  7. def oRGB(rgb): # pass
  8.     r,g,b = rgb
  9.     return "#%02x%02x%02x" % (r,g,b)
  10.  
  11. ww = 600
  12. hh = 600
  13. root = Tk()
  14. root.title("# Tk_no_ones_radial_3")
  15. root.geometry("%dx%d+0+0"%(ww,hh))
  16. canvas = Canvas(root, width=ww, height=hh)
  17. canvas.grid()
  18.  
  19. # set up spiral
  20. step = 1
  21. state = 0
  22. numSteps = 1
  23. turnCounter = 1
  24. stepSize = 5
  25. cols = ww / stepSize
  26. rows = hh / stepSize
  27. totalSteps = cols * rows
  28. x0= ww / 2
  29. y0 = hh / 2
  30.  
  31. xy = []
  32. for y in range(0,hh,stepSize):
  33.     for x in range(0,ww,stepSize):
  34.         distance = sqrt((x0-x)**2+(y0-y)**2)
  35.         xy2 = atan2(x-x0,y-y0)
  36.         xy.append(((int(distance), xy2),x,y))
  37.        
  38. xy.sort()
  39.  
  40. xy = [(x,y) for z,x,y in xy]
  41.  
  42. COLORS = 'red orange yellow green blue purple'.split()
  43. t = stepSize
  44. i = 12345
  45. iii = 0
  46. ttt = 0
  47. s = ''
  48. Lc = len(COLORS)
  49.  
  50. while 1:
  51.     canvas.delete('all')
  52.     c = 1
  53.     for x,y in xy:
  54.         while 1:
  55.             if len(s) < 100:
  56.                 s += str(i).replace('1','')
  57.                 i += 1
  58.             if s:
  59.                 if ttt < 1:
  60.                     ttt = int(s[:2])*c
  61.                     s = s[2:]
  62.                     iii = (iii+1)%Lc
  63.                     color = int(iii)
  64.                 canvas.create_rectangle((x,y,x+t,y+t), fill=COLORS[color], outline='')
  65.                 c += 0.0025
  66.                 break
  67.         ttt -= 1
  68.            
  69.     canvas.update()
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement