tixy2.py

Created by schraf

Created on March 04, 2024

604 Bytes


from math import *
from kandinsky import *
from time import *
from random import *

ms = .01
fill_rect(0, 0, 320, 222, (0, 0, 0))

def f(t, i, x, y): return sin(t-sqrt((x-7.5)**2+(y-6)**2))

def hypot(a, b): return sqrt(a * a + b * b)

def carre(x, y, v):
 t = int(14 * v)
 g, h = 64 + 14 * x, 15 + 14 * y
 coul = (255 + 255 * v,) * 3
 fill_rect(g - 6 + t, h - 6, 14 - t, 14, (0,0,0))
 fill_rect(g - 6, h - 6, t, 14, coul)

def tixy():
 t = 0
 while True:
  for i in range(256):
   x, y = i % 16, i // 16
   v = min(1, max(-1, f(t, i, x, y)))
   carre(x, y, v)
  sleep(ms)
  t += ms

tixy()