here2share

# Tk_checker_ani.py

Jan 14th, 2022 (edited)
1,006
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. # Tk_checker_ani.py
  2.  
  3. from random import randint as rndi
  4. from tkinter import *
  5. from math import cos, sin, radians, floor
  6.  
  7. ww = 500
  8. hh = 500
  9.  
  10. def rgb(r,g,b):
  11.     return '#{:02x}{:02x}{:02x}'.format(r,g,b)
  12. bg_color = rgb(136,19,8)
  13.  
  14. root = Tk()
  15. canvas = Canvas(root,width=ww,height=hh,bg=bg_color)
  16. canvas.pack()
  17. '''
  18. s=50,r=0,draw=a=>{for(r||createCanvas(W=500,W,WEBGL),background(136,19,8),i=0;
  19. i<121;i++)push(),translate(i%11*s-W/2,floor(i/11)*s-W/2,0),rotateY(i/22+r),
  20. rotateX(sin(r/10)/2),fill([0,255][i%2]),box(s,s,1),pop();r+=.05}
  21. '''
  22.  
  23. s=50
  24. s2=s/2
  25. r=0
  26. while 1:
  27.     canvas.delete('all')
  28.     for i in range(121):
  29.         zzz = sin(r*0.01)*1 ###
  30.         x,y = int(i%11*s)-250, int(floor(i/11)*s) ###
  31.         x2 = sin(i*0.05+r)/2*s ###
  32.         y2 = s2-(cos(i/11+r)/2*22*zzz)
  33.         fg_color = ['white','black'][i%2] ###
  34.         box = [(x+xx+y2*10,y+yy) for xx,yy in [(-x2,-s2),(-x2,y2),(x2,s2),(x2,-y2)]]
  35.         canvas.create_polygon(box,fill=fg_color,outline='')
  36.         r=r+0.0002
  37.     canvas.update()
Add Comment
Please, Sign In to add comment