tixy.py

Created by schraf

Created on November 20, 2023

618 Bytes

Quelques exemples :

def f(t, i, x, y): return sin(y/8+t)
def f(t, i, x, y): return random()
def f(t, i, x, y): return sin(t)
def f(t, i, x, y): return i / 256
def f(t, i, x, y): return x / 16
def f(t, i, x, y): return y - 7.5
def f(t, i, x, y): return y - t
def f(t, i, x, y): return [1, 0, -1][i%3]
def f(t, i, x, y): return sin(t-sqrt((x-7.5)**2+(y-6)**2))
def f(t, i, x, y): return (y > x) and (14-x < y)
def f(t, i, x, y): return (int(t*10)) & (1<<x) and y==8
def f(t, i, x, y): return random() * 2 - 1
def f(t, i, x, y): return cos(t + i + x * y)
def f(t, i, x, y): return sin(x/2) - sin(x-t) - y+6
def f(t, i, x, y): return -.4/(.01+hypot(x-t%10,y-t%8)-t%2*9)
def f(t, i, x, y): return .02/sin(3**(x+1)-atan2(x+1,(x+1)*y)*3-t)
def f(t, i, x, y): return sin(atan2(x-8,y+5)*8+sin(y)+t*4)
def f(t, i, x, y): return x & 1 if cos((i|17)**2+t)>0 else y & 1
def f(t, i, x, y): return (16*(1+sin(t+x))<(x+y))*sin(x-t)
def f(t, i, x, y): return sin((x & y)/(.01 + sin((t/3)%3)*38-y-x))


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

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

def f(t, i, x, y): return 8*t%13 - hypot(x-7.5, y-7.5)

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

def carre(x, y, v):
 t = int(5 * abs(v))
 g, h = 64 + 12 * x, 15 + 12 * y
 coul = (255,) * 3 if v >= 0 else (255, 0, 0)
 fill_rect(g - 6, h - 6, 12, 12, (0,0,0))
 fill_rect(g - t, h - t, 2 * t, 2 * t, 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()

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.